for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Buttress\Concrete\Route;
use FastRoute\RouteCollector as Collector;
use function FastRoute\simpleDispatcher;
/**
* A Dispatcher wrapper that adjusts the API to work with CLI
*/
class Dispatcher
{
public function __construct(\FastRoute\Dispatcher $dispatcher)
$this->dispatcher = $dispatcher;
dispatcher
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
class MyClass { } $x = new MyClass(); $x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:
class MyClass { public $foo; } $x = new MyClass(); $x->foo = true;
}
* Dispatches against the provided HTTP method verb and URI.
*
* Returns array with one of the following formats:
* [self::NOT_FOUND]
* [self::METHOD_NOT_ALLOWED, ['GET', 'OTHER_ALLOWED_METHODS']]
* [self::FOUND, $handler, ['varName' => 'value', ...]]
* @param string $command
* @return array
public function dispatch($command)
return $this->dispatcher->dispatch('get', $command);
* Get a new instance of dispatcher
* @param callable $routeDefinitionCallback
* @param array $options
* @return static
public static function simpleDispatcher(callable $routeDefinitionCallback, array $options = [])
return new static(simpleDispatcher(function (Collector $collector) use ($routeDefinitionCallback) {
return $routeDefinitionCallback(new RouteCollector($collector));
}, $options));
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: