for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php declare(strict_types = 1);
namespace jschreuder\Middle\Controller;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
final class CallableController implements ControllerInterface
{
public static function fromCallable(callable $closure) : self
return new self($closure);
}
public static function factoryFromCallable(callable $closure) : callable
return function () use ($closure) {
return self::fromCallable($closure);
};
/** @var callable */
private $closure;
private function __construct(callable $closure)
$this->closure = $closure;
public function execute(ServerRequestInterface $request) : ResponseInterface
return ($this->closure)($request);