AbstractController::withStorage()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 6
ccs 4
cts 4
cp 1
crap 1
rs 10
1
<?php
2
3
namespace BenTools\MercurePHP\Controller;
4
5
use BenTools\MercurePHP\Configuration\WithConfigTrait;
6
use BenTools\MercurePHP\Storage\StorageInterface;
7
use BenTools\MercurePHP\Transport\TransportInterface;
8
use BenTools\Psr7\RequestMatcherInterface;
9
use Psr\Http\Message\ServerRequestInterface;
10
use Psr\Log\LoggerInterface;
11
use React\Promise\PromiseInterface;
12
13
abstract class AbstractController implements RequestMatcherInterface
14
{
15
    use WithConfigTrait;
16
17
    protected LoggerInterface $logger;
18
    protected TransportInterface $transport;
19
    protected StorageInterface $storage;
20
21
    abstract public function __invoke(ServerRequestInterface $request): PromiseInterface;
22
23 29
    final public function withTransport(TransportInterface $transport): self
24
    {
25 29
        $clone = clone $this;
26 29
        $clone->transport = $transport;
27
28 29
        return $clone;
29
    }
30
31 29
    final public function withStorage(StorageInterface $storage): self
32
    {
33 29
        $clone = clone $this;
34 29
        $clone->storage = $storage;
35
36 29
        return $clone;
37
    }
38
}
39