Laminas::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 3

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 8
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 3
nop 0
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Conia\Chuck\Psr;
6
7
use Conia\Chuck\Exception\RuntimeException;
8
use Laminas\Diactoros\ResponseFactory;
9
use Laminas\Diactoros\ServerRequestFactory;
10
use Laminas\Diactoros\StreamFactory;
11
use Psr\Http\Message\ServerRequestInterface as PsrServerRequest;
12
use Throwable;
13
14
/** @psalm-api */
15
class Laminas extends AbstractFactory
16
{
17 3
    public function __construct()
18
    {
19
        try {
20 3
            $this->responseFactory = new ResponseFactory();
21 3
            $this->streamFactory = new StreamFactory();
22
            // @codeCoverageIgnoreStart
23
        } catch (Throwable) {
24
            throw new RuntimeException('Install nyholm/psr7-server');
25
            // @codeCoverageIgnoreEnd
26
        }
27
    }
28
29 2
    public function request(): PsrServerRequest
30
    {
31 2
        return ServerRequestFactory::fromGlobals();
32
    }
33
}
34