original_string: public function setLimit($limit)
      {
          if (is_array($limit)) {
              $spec = $limit;
              if (!isset($spec['name'])) {
                  throw new \Exception("Cannot create Limit: Name missing from configuration.");
              }
              $name = $spec['name'];
              $limit = isset($spec['limit']) ? $spec['limit'] : null;
              $interval = isset($spec['interval']) ? $spec['interval'] : null;
              $actions = isset($spec['actions']) ? $spec['actions'] : array();
              
              $limit = new Limit($name, $limit, $interval);
              
              foreach ($actions as $action) {
                  if (is_string($action)) {
                      $action = $this->getActionPlugins()->get($action);
                  } elseif (is_array($action)) {
                      if (!isset($action['name'])) {
                          throw new \Exception('Cannot create Action: Name missing from configuration.');
                      }
                      $action = $this->getActionPlugins()->get($action['name'], $action);
                  }
                  
                  if (!$action instanceof Action\ActionInterface) {
                      throw new \Exception("Action must be instance of Spork\Mvc\Listener\Limit\Action\ActionInterface");
                  }
                  
                  $limit->addAction($action);
              }
          }
          
          if (!$limit instanceof Limit) {
              throw new \Exception("Limit must be instance of Spork\Mvc\Listener\Limit\Limit");
          }
          
          $this->limits[$limit->getName()] = $limit;
      }
code: public function setLimit($limit)
      {
          if (is_array($limit)) {
              $spec = $limit;
              if (!isset($spec['name'])) {
                  throw new \Exception("Cannot create Limit: Name missing from configuration.");
              }
              $name = $spec['name'];
              $limit = isset($spec['limit']) ? $spec['limit'] : null;
              $interval = isset($spec['interval']) ? $spec['interval'] : null;
              $actions = isset($spec['actions']) ? $spec['actions'] : array();
              
              $limit = new Limit($name, $limit, $interval);
              
              foreach ($actions as $action) {
                  if (is_string($action)) {
                      $action = $this->getActionPlugins()->get($action);
                  } elseif (is_array($action)) {
                      if (!isset($action['name'])) {
                          throw new \Exception('Cannot create Action: Name missing from configuration.');
                      }
                      $action = $this->getActionPlugins()->get($action['name'], $action);
                  }
                  
                  if (!$action instanceof Action\ActionInterface) {
                      throw new \Exception("Action must be instance of Spork\Mvc\Listener\Limit\Action\ActionInterface");
                  }
                  
                  $limit->addAction($action);
              }
          }
          
          if (!$limit instanceof Limit) {
              throw new \Exception("Limit must be instance of Spork\Mvc\Listener\Limit\Limit");
          }
          
          $this->limits[$limit->getName()] = $limit;
      }
code_tokens: public function setLimit ( $ limit ) { if ( is_array ( $ limit ) ) { $ spec = $ limit ; if ( ! isset ( $ spec [ 'name' ] ) ) { throw new \ Exception ( "Cannot create Limit: Name missing from configuration." ) ; } $ name = $ spec [ 'name' ] ; $ limit = isset ( $ spec [ 'limit' ] ) ? $ spec [ 'limit' ] : null ; $ interval = isset ( $ spec [ 'interval' ] ) ? $ spec [ 'interval' ] : null ; $ actions = isset ( $ spec [ 'actions' ] ) ? $ spec [ 'actions' ] : array ( ) ; $ limit = new Limit ( $ name , $ limit , $ interval ) ; foreach ( $ actions as $ action ) { if ( is_string ( $ action ) ) { $ action = $ this -> getActionPlugins ( ) -> get ( $ action ) ; } elseif ( is_array ( $ action ) ) { if ( ! isset ( $ action [ 'name' ] ) ) { throw new \ Exception ( 'Cannot create Action: Name missing from configuration.' ) ; } $ action = $ this -> getActionPlugins ( ) -> get ( $ action [ 'name' ] , $ action ) ; } if ( ! $ action instanceof Action \ ActionInterface ) { throw new \ Exception ( "Action must be instance of Spork\Mvc\Listener\Limit\Action\ActionInterface" ) ; } $ limit -> addAction ( $ action ) ; } } if ( ! $ limit instanceof Limit ) { throw new \ Exception ( "Limit must be instance of Spork\Mvc\Listener\Limit\Limit" ) ; } $ this -> limits [ $ limit -> getName ( ) ] = $ limit ; }
docstring: Set a limit
  
  @param Limit|array $limit
  @throws \Exception
docstring_tokens: Set a limit