Completed
Push — master ( 06a790...975a47 )
by maxime
03:26
created

AbstractModule   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 24
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A process() 0 10 1
createContainer() 0 1 ?
createPipeline() 0 1 ?
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Aidphp\Framework;
6
7
use Psr\Http\Server\MiddlewareInterface;
8
use Psr\Http\Server\RequestHandlerInterface;
9
10
use Aidphp\Di\CompositeContainerInterface;
11
use Psr\Container\ContainerInterface;
12
13
use Psr\Http\Message\ServerRequestInterface;
14
use Psr\Http\Message\ResponseInterface;
15
16
abstract class AbstractModule implements MiddlewareInterface
17
{
18
    protected $dic;
19
20 1
    public function __construct(CompositeContainerInterface $dic)
21
    {
22 1
        $this->dic = $dic;
23 1
    }
24
25 1
    public function process(ServerRequestInterface $req, RequestHandlerInterface $handler): ResponseInterface
26
    {
27 1
        $this->dic->push($this->createContainer());
28
29 1
        $res = $this->createPipeline($this->dic)->process($req, $handler);
30
31 1
        $this->dic->pop();
32
33 1
        return $res;
34
    }
35
36
    abstract protected function createContainer(): ContainerInterface;
37
38
    abstract protected function createPipeline(ContainerInterface $dic): MiddlewareInterface;
39
}