AbstractMiddleware   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 19
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 1 1
A setRequest() 0 2 1
A __invoke() 0 2 1
A addMatcher() 0 2 1
1
<?php
2
3
namespace Lepton\Middleware;
4
5
use Lepton\Http\Request;
6
use Lepton\Http\Response\HttpResponse;
7
use Lepton\Routing\Match\BaseMatch;
8
9
// Abstract Middleware to be used in Routing
10
11
abstract class AbstractMiddleware{
12
13
  public BaseMatch $match;
14
  public Request $request;
15
16
  public function __construct(){  }
17
18
  abstract protected function handle(mixed ...$args): HttpResponse|Request;
19
20
  public function addMatcher(BaseMatch $match){
21
    $this->match = $match;
22
  }
23
24
  public function setRequest(Request $request){
25
    $this->request = $request;
26
  }
27
28
  public function __invoke(mixed ...$args) {
29
        return $this->handle(...$args);
30
    }
31
}