Phlyty\Route::respondsTo PHP Method

respondsTo() public method

If no method is provided, returns array of all methods to which this route will respond.
public respondsTo ( null | string $method = null ) : array | boolean
$method null | string
return array | boolean
    public function respondsTo($method = null)
    {
        if (null === $method) {
            return array_keys($this->methods);
        }
        $method = strtoupper($method);
        return isset($this->methods[$method]);
    }

Usage Example

コード例 #1
0
ファイル: App.php プロジェクト: phly/phlyty
 /**
  * Determine what methods a route responds to
  *
  * @param  Route $route
  * @param  int   $index
  */
 protected function registerRouteMethods(Route $route, $index)
 {
     foreach ($route->respondsTo() as $method) {
         if (!isset($this->routesByMethod[$method])) {
             $this->routesByMethod[$method] = [];
         }
         $this->routesByMethod[$method][$index] = $route;
     }
 }