Passed
Push — main ( 92bf86...8347d6 )
by Thomas
02:44
created

Nyholm   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A request() 0 10 1
A __construct() 0 7 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Conia\Chuck\Http;
6
7
use Conia\Chuck\Exception\RuntimeException;
8
use Nyholm\Psr7\Factory\Psr17Factory;
9
use Nyholm\Psr7Server\ServerRequestCreator;
10
use Psr\Http\Message\ServerRequestInterface;
11
use Throwable;
12
13
class Nyholm extends AbstractFactory
14
{
15
    protected Psr17Factory $factory;
16
17 67
    public function __construct()
18
    {
19
        try {
20 67
            $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 9
    public function request(): ServerRequestInterface
29
    {
30 9
        $creator = new ServerRequestCreator(
31 9
            $this->factory, // ServerRequestFactory
32 9
            $this->factory, // UriFactory
33 9
            $this->factory, // UploadedFileFactory
34 9
            $this->factory  // StreamFactory
35 9
        );
36
37 9
        return $creator->fromGlobals();
38
    }
39
}
40