This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
indieauth/src/Middleware/ClosureRequestHandler.php

24 lines
640 B
PHP

<?php declare(strict_types=1);
namespace Taproot\IndieAuth\Middleware;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Server\RequestHandlerInterface;
class ClosureRequestHandler implements RequestHandlerInterface {
protected $callable;
/** @var array $args */
protected $args;
public function __construct(callable $callable) {
$this->callable = $callable;
$this->args = array_slice(func_get_args(), 1);
}
public function handle(ServerRequestInterface $request): ResponseInterface {
return call_user_func_array($this->callable, array_merge([$request], $this->args));
}
}