| 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\Factory\Psr17;
|
|
|
12 |
|
|
|
13 |
use Closure;
|
|
|
14 |
use Psr\Http\Message\ServerRequestInterface;
|
|
|
15 |
use Slim\Interfaces\ServerRequestCreatorInterface;
|
|
|
16 |
|
|
|
17 |
class ServerRequestCreator implements ServerRequestCreatorInterface
|
|
|
18 |
{
|
|
|
19 |
/**
|
|
|
20 |
* @var object|string
|
|
|
21 |
*/
|
|
|
22 |
protected $serverRequestCreator;
|
|
|
23 |
|
|
|
24 |
protected string $serverRequestCreatorMethod;
|
|
|
25 |
|
|
|
26 |
/**
|
|
|
27 |
* @param object|string $serverRequestCreator
|
|
|
28 |
*/
|
|
|
29 |
public function __construct($serverRequestCreator, string $serverRequestCreatorMethod)
|
|
|
30 |
{
|
|
|
31 |
$this->serverRequestCreator = $serverRequestCreator;
|
|
|
32 |
$this->serverRequestCreatorMethod = $serverRequestCreatorMethod;
|
|
|
33 |
}
|
|
|
34 |
|
|
|
35 |
/**
|
|
|
36 |
* {@inheritdoc}
|
|
|
37 |
*/
|
|
|
38 |
public function createServerRequestFromGlobals(): ServerRequestInterface
|
|
|
39 |
{
|
|
|
40 |
/** @var callable $callable */
|
|
|
41 |
$callable = [$this->serverRequestCreator, $this->serverRequestCreatorMethod];
|
|
|
42 |
return (Closure::fromCallable($callable))();
|
|
|
43 |
}
|
|
|
44 |
}
|