Passed
Push — main ( a1a461...2097df )
by Thomas
12:50
created

Nyholm   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
eloc 12
dl 0
loc 25
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 2
A request() 0 10 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Conia\Chuck\Psr;
6
7
use Conia\Chuck\Exception\RuntimeException;
8
use Nyholm\Psr7\Factory\Psr17Factory;
9
use Nyholm\Psr7Server\ServerRequestCreator;
10
use Psr\Http\Message\ServerRequestInterface as PsrServerRequest;
11
use Throwable;
12
13
class Nyholm extends AbstractFactory
14
{
15
    protected Psr17Factory $factory;
16
17 75
    public function __construct()
18
    {
19
        try {
20 75
            $this->factory = $this->streamFactory = $this->responseFactory = new Psr17Factory();
21
            // @codeCoverageIgnoreStart
22
        } catch (Throwable) {
23
            throw new RuntimeException('Install laminas/laminas-diactoros');
24
            // @codeCoverageIgnoreEnd
25
        }
26
    }
27
28 11
    public function request(): PsrServerRequest
29
    {
30 11
        $creator = new ServerRequestCreator(
31 11
            $this->factory, // ServerRequestFactory
32 11
            $this->factory, // UriFactory
33 11
            $this->factory, // UploadedFileFactory
34 11
            $this->factory  // StreamFactory
35 11
        );
36
37 11
        return $creator->fromGlobals();
38
    }
39
}
40