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

AbstractModule::createContainer()

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 1
ccs 0
cts 0
cp 0
c 0
b 0
f 0
nc 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
}