Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1441 ariadna 1
<?php
2
 
3
/**
4
 * Slim Framework (https://slimframework.com)
5
 *
6
 * @license https://github.com/slimphp/Slim/blob/4.x/LICENSE.md (MIT License)
7
 */
8
 
9
declare(strict_types=1);
10
 
11
namespace Slim\Handlers\Strategies;
12
 
13
use Psr\Http\Message\ResponseInterface;
14
use Psr\Http\Message\ServerRequestInterface;
15
use Slim\Interfaces\InvocationStrategyInterface;
16
use RuntimeException;
17
 
18
/**
19
 * Route callback strategy with route parameters as individual arguments.
20
 */
21
class RequestResponseNamedArgs implements InvocationStrategyInterface
22
{
23
    public function __construct()
24
    {
25
        if (PHP_VERSION_ID < 80000) {
26
            throw new RuntimeException('Named arguments are only available for PHP >= 8.0.0');
27
        }
28
    }
29
 
30
    /**
31
     * Invoke a route callable with request, response and all route parameters
32
     * as individual arguments.
33
     *
34
     * @param array<string, string>  $routeArguments
35
     */
36
    public function __invoke(
37
        callable $callable,
38
        ServerRequestInterface $request,
39
        ResponseInterface $response,
40
        array $routeArguments
41
    ): ResponseInterface {
42
        return $callable($request, $response, ...$routeArguments);
43
    }
44
}