Ejemplo n.º 1
0
 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());
 }
Ejemplo n.º 2
0
 /**
  * @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;
 }