bytic /
http
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace Nip\Http\ServerMiddleware\Traits; |
||||
| 4 | |||||
| 5 | use Nip\Http\Response\Response; |
||||
| 6 | use Nip\Request; |
||||
| 7 | |||||
| 8 | /** |
||||
| 9 | * Class HasServerMiddleware |
||||
| 10 | * @package Nip\Http\ServerMiddleware |
||||
| 11 | */ |
||||
| 12 | trait HasServerMiddleware |
||||
| 13 | { |
||||
| 14 | |||||
| 15 | /** |
||||
| 16 | * The application's middleware stack. |
||||
| 17 | * |
||||
| 18 | * @var array |
||||
| 19 | */ |
||||
| 20 | protected $middleware = []; |
||||
| 21 | |||||
| 22 | |||||
| 23 | /** |
||||
| 24 | * Determine if the kernel has a given middleware. |
||||
| 25 | * |
||||
| 26 | * @param string $middleware |
||||
| 27 | * @return bool |
||||
| 28 | */ |
||||
| 29 | public function hasMiddleware($middleware) |
||||
| 30 | { |
||||
| 31 | return in_array($middleware, $this->middleware); |
||||
| 32 | } |
||||
| 33 | |||||
| 34 | /** |
||||
| 35 | * Add a new middleware to beginning of the stack if it does not already exist. |
||||
| 36 | * |
||||
| 37 | * @param string $middleware |
||||
| 38 | * @return $this |
||||
| 39 | */ |
||||
| 40 | public function prependMiddleware($middleware) |
||||
| 41 | { |
||||
| 42 | if (array_search($middleware, $this->middleware) === false) { |
||||
| 43 | array_unshift($this->middleware, $middleware); |
||||
| 44 | } |
||||
| 45 | return $this; |
||||
| 46 | } |
||||
| 47 | |||||
| 48 | /** |
||||
| 49 | * Add a new middleware to end of the stack if it does not already exist. |
||||
| 50 | * |
||||
| 51 | * @param string $middleware |
||||
| 52 | * @return $this |
||||
| 53 | */ |
||||
| 54 | public function pushMiddleware($middleware) |
||||
| 55 | { |
||||
| 56 | if (array_search($middleware, $this->middleware) === false) { |
||||
| 57 | $this->middleware[] = $middleware; |
||||
| 58 | } |
||||
| 59 | return $this; |
||||
| 60 | } |
||||
| 61 | |||||
| 62 | |||||
| 63 | /** |
||||
| 64 | * Call the terminate method on any terminable middleware. |
||||
| 65 | * |
||||
| 66 | * @param Request $request |
||||
| 67 | * @param Response $response |
||||
| 68 | * @return void |
||||
| 69 | */ |
||||
| 70 | protected function terminateMiddleware($request, $response) |
||||
|
0 ignored issues
–
show
The parameter
$response is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
|
|||||
| 71 | { |
||||
| 72 | } |
||||
| 73 | } |
||||
| 74 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.