AbstractMiddleware::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 1
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 0
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 1
rs 10
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
}