AbstractController   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 24
ccs 8
cts 8
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A withStorage() 0 6 1
A withTransport() 0 6 1
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