AbstractHandler::addMiddlewares()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 2
rs 10
1
<?php
2
3
namespace Lepton\Core\Handler;
4
use Lepton\Http\Request;
5
use Lepton\Http\Response\HttpResponse;
6
use Lepton\Routing\Match\BaseMatch;
7
8
abstract class AbstractHandler
9
{
10
    abstract protected function handle(BaseMatch $matcher) : HttpResponse;
11
    abstract protected function resolveRequest() : BaseMatch;
12
13
14
    protected Request $request;
15
    protected $middlewares = array();
16
17
    public function __construct($request){
18
      $this->request = $request;
19
    }
20
21
    public function addMiddlewares($middlewares) {
22
        $this->middlewares = $middlewares;
23
    }
24
25
26
    public function getResponse() : HttpResponse{
27
      $matcher = $this->resolveRequest();
28
      return $this->handle($matcher);
29
30
    }
31
32
33
34
  }
35
36