Nyholm   A
last analyzed

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
/** @psalm-api */
14
class Nyholm extends AbstractFactory
15
{
16
    protected Psr17Factory $factory;
17
18 75
    public function __construct()
19
    {
20
        try {
21 75
            $this->factory = $this->streamFactory = $this->responseFactory = new Psr17Factory();
22
            // @codeCoverageIgnoreStart
23
        } catch (Throwable) {
24
            throw new RuntimeException('Install laminas/laminas-diactoros');
25
            // @codeCoverageIgnoreEnd
26
        }
27
    }
28
29 10
    public function request(): PsrServerRequest
30
    {
31 10
        $creator = new ServerRequestCreator(
32 10
            $this->factory, // ServerRequestFactory
33 10
            $this->factory, // UriFactory
34 10
            $this->factory, // UploadedFileFactory
35 10
            $this->factory  // StreamFactory
36 10
        );
37
38 10
        return $creator->fromGlobals();
39
    }
40
}
41