original_string: public function api($match, $apiController, $kwargs = [], $methods = null)
      {
          if (is_string($methods)) {
              $methods = array($methods);
          }
          if (! is_array($kwargs)) { // @codeCoverageIgnore
              $kwargs = []; // @codeCoverageIgnore
          }
          if ($methods === null) {
              $methods = ['GET', 'POST', 'PUT', 'DELETE', 'PATCH'];
          }
  
          $methods = array_map('strtoupper', $methods);
  
          if ($match === '') { // @codeCoverageIgnore
              throw new RouterException('Your API route must contain a first match field when registering!'); // @codeCoverageIgnore
          }
          if (substr($match, 0, 1) !== '/') {
              $match = '/' . $match;
          }
  
          foreach ($methods as $method) {
              switch ($method)
              {
                  case 'GET':
                      $this->get($match, $apiController, array_merge($kwargs, ['api_method' => 'list']));
                      $this->get($match . '/(!?)', $apiController, array_merge($kwargs, ['api_method' => 'retrieve']));
                      break;
                  case 'POST':
                      $this->post($match, $apiController, array_merge($kwargs, ['api_method' => 'create']));
                      break;
                  case 'PUT':
                      $this->put($match . '/(!?)', $apiController, array_merge($kwargs, ['api_method' => 'update']));
                      break;
                  case 'PATCH':
                      $this->patch($match . '/(!?)', $apiController, array_merge($kwargs, ['api_method' => 'partialUpdate']));
                      break;
                  case 'DELETE':
                      $this->delete($match . '/(!?)', $apiController, array_merge($kwargs, ['api_method' => 'destroy']));
                      break;
              }
          }
      }
code: public function api($match, $apiController, $kwargs = [], $methods = null)
      {
          if (is_string($methods)) {
              $methods = array($methods);
          }
          if (! is_array($kwargs)) { // @codeCoverageIgnore
              $kwargs = []; // @codeCoverageIgnore
          }
          if ($methods === null) {
              $methods = ['GET', 'POST', 'PUT', 'DELETE', 'PATCH'];
          }
  
          $methods = array_map('strtoupper', $methods);
  
          if ($match === '') { // @codeCoverageIgnore
              throw new RouterException('Your API route must contain a first match field when registering!'); // @codeCoverageIgnore
          }
          if (substr($match, 0, 1) !== '/') {
              $match = '/' . $match;
          }
  
          foreach ($methods as $method) {
              switch ($method)
              {
                  case 'GET':
                      $this->get($match, $apiController, array_merge($kwargs, ['api_method' => 'list']));
                      $this->get($match . '/(!?)', $apiController, array_merge($kwargs, ['api_method' => 'retrieve']));
                      break;
                  case 'POST':
                      $this->post($match, $apiController, array_merge($kwargs, ['api_method' => 'create']));
                      break;
                  case 'PUT':
                      $this->put($match . '/(!?)', $apiController, array_merge($kwargs, ['api_method' => 'update']));
                      break;
                  case 'PATCH':
                      $this->patch($match . '/(!?)', $apiController, array_merge($kwargs, ['api_method' => 'partialUpdate']));
                      break;
                  case 'DELETE':
                      $this->delete($match . '/(!?)', $apiController, array_merge($kwargs, ['api_method' => 'destroy']));
                      break;
              }
          }
      }
code_tokens: public function api ( $ match , $ apiController , $ kwargs = [ ] , $ methods = null ) { if ( is_string ( $ methods ) ) { $ methods = array ( $ methods ) ; } if ( ! is_array ( $ kwargs ) ) { // @codeCoverageIgnore $ kwargs = [ ] ; // @codeCoverageIgnore } if ( $ methods === null ) { $ methods = [ 'GET' , 'POST' , 'PUT' , 'DELETE' , 'PATCH' ] ; } $ methods = array_map ( 'strtoupper' , $ methods ) ; if ( $ match === '' ) { // @codeCoverageIgnore throw new RouterException ( 'Your API route must contain a first match field when registering!' ) ; // @codeCoverageIgnore } if ( substr ( $ match , 0 , 1 ) !== '/' ) { $ match = '/' . $ match ; } foreach ( $ methods as $ method ) { switch ( $ method ) { case 'GET' : $ this -> get ( $ match , $ apiController , array_merge ( $ kwargs , [ 'api_method' => 'list' ] ) ) ; $ this -> get ( $ match . '/(!?)' , $ apiController , array_merge ( $ kwargs , [ 'api_method' => 'retrieve' ] ) ) ; break ; case 'POST' : $ this -> post ( $ match , $ apiController , array_merge ( $ kwargs , [ 'api_method' => 'create' ] ) ) ; break ; case 'PUT' : $ this -> put ( $ match . '/(!?)' , $ apiController , array_merge ( $ kwargs , [ 'api_method' => 'update' ] ) ) ; break ; case 'PATCH' : $ this -> patch ( $ match . '/(!?)' , $ apiController , array_merge ( $ kwargs , [ 'api_method' => 'partialUpdate' ] ) ) ; break ; case 'DELETE' : $ this -> delete ( $ match . '/(!?)' , $ apiController , array_merge ( $ kwargs , [ 'api_method' => 'destroy' ] ) ) ; break ; } } }
docstring: Register an API entity class with a base match.
  
  @param string $match The base match for the list and create routes. The other routes will contain this as prefix.
  @param string $apiController Api Controller class name, with full namespace notation.
  @param array $kwargs Any optional kwargs that will be passed to the controller (via route).
  @param array|null $methods Methods to generate. Null for all. Example: ['GET'] or ['GET', 'POST'].
  
  @throws RouterException
docstring_tokens: Register an API entity class with a base match .