Passed
Push — develop ( bc7c49...ecfe6e )
by Fabian
01:26
created

Service::getUriFactory()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cakasim\Payone\Sdk\Http;
6
7
use Cakasim\Payone\Sdk\AbstractService;
8
use Psr\Container\ContainerInterface;
9
use Psr\Http\Message\ServerRequestFactoryInterface;
10
use Psr\Http\Message\ServerRequestInterface;
11
12
/**
13
 * The HTTP service.
14
 *
15
 * @author Fabian Böttcher <[email protected]>
16
 * @since 0.1.0
17
 */
18
class Service extends AbstractService
19
{
20
    /**
21
     * @var ServerRequestFactoryInterface The PSR-17 server request factory instance.
22
     */
23
    protected $serverRequestFactory;
24
25
    /**
26
     * Constructs the HTTP service.
27
     *
28
     * @param ServerRequestFactoryInterface $serverRequestFactory The server request factory.
29
     * @inheritDoc
30
     */
31
    public function __construct(
32
        ContainerInterface $container,
33
        ServerRequestFactoryInterface $serverRequestFactory
34
    ) {
35
        parent::__construct($container);
36
        $this->serverRequestFactory = $serverRequestFactory;
37
    }
38
39
    /**
40
     * Create a server request from the current environment.
41
     *
42
     * @return ServerRequestInterface The created server request.
43
     */
44
    public function createServerRequest(): ServerRequestInterface
45
    {
46
        return $this->serverRequestFactory->createServerRequest(
47
            $_SERVER['REQUEST_METHOD'],
48
            $_SERVER['REQUEST_URI'],
49
            $_SERVER
50
        );
51
    }
52
}
53