コード例 #1
0
ファイル: RouteTest.php プロジェクト: lytc/sloths
 public function testMethods()
 {
     $route = new Route('GET', '/', function () {
     });
     $this->assertSame(['GET'], $route->getMethods());
     $this->assertTrue($route->hasMethod('GET'));
     $route = new Route('*', '/', function () {
     });
     $this->assertSame(\Sloths\Http\AbstractRequest::getSupportedMethods(), $route->getMethods());
 }
コード例 #2
0
ファイル: Route.php プロジェクト: lytc/sloths
 /**
  * @param $methods
  * @param $pattern
  * @param callable $callback
  */
 public function __construct($methods, $pattern, callable $callback)
 {
     if ('*' == $methods) {
         $methods = AbstractRequest::getSupportedMethods();
     } else {
         if (!is_array($methods)) {
             $methods = [$methods];
         }
     }
     $this->methods = array_values($methods);
     $this->pattern = $pattern;
     $this->callback = $callback;
 }