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()); }
/** * @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; }