Service   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 7
Bugs 0 Features 0
Metric Value
eloc 8
dl 0
loc 32
rs 10
c 7
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createServerRequest() 0 6 1
A __construct() 0 6 1
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