| @@ -49,9 +49,9 @@ | ||
| 49 | 49 | private $steps = [self::ATTEMPT => [], self::SIGN => [], self::BUILD => [], self::VALIDATE => [], self::INIT => []]; |
| 50 | 50 | /** |
| 51 | 51 | * @param callable $handler HTTP handler. |
| 52 | 52 | */ |
| 53 | - public function __construct(callable $handler = null) | |
| 53 | + public function __construct(?callable $handler = null) | |
| 54 | 54 | { |
| 55 | 55 | $this->handler = $handler; |
| 56 | 56 | } |
| 57 | 57 | /** |
| @@ -97,8 +97,21 @@ | ||
| 97 | 97 | { |
| 98 | 98 | return (bool) $this->handler; |
| 99 | 99 | } |
| 100 | 100 | /** |
| 101 | + * Checks if a middleware exists. The middleware | |
| 102 | + * should have been added with a name in order to | |
| 103 | + * use this method. | |
| 104 | + * | |
| 105 | + * @param string $name | |
| 106 | + * | |
| 107 | + * @return bool | |
| 108 | + */ | |
| 109 | + public function hasMiddleware(string $name) : bool | |
| 110 | + { | |
| 111 | + return isset($this->named[$name]); | |
| 112 | + } | |
| 113 | + /** | |
| 101 | 114 | * Append a middleware to the init step. |
| 102 | 115 | * |
| 103 | 116 | * @param callable $middleware Middleware function to add. |
| 104 | 117 | * @param string $name Name of the middleware. |
| @@ -245,9 +258,9 @@ | ||
| 245 | 258 | * object. |
| 246 | 259 | * |
| 247 | 260 | * @param callable|null $fn Pass null to remove any previously set function |
| 248 | 261 | */ |
| 249 | - public function interpose(callable $fn = null) | |
| 262 | + public function interpose(?callable $fn = null) | |
| 250 | 263 | { |
| 251 | 264 | $this->sorted = null; |
| 252 | 265 | $this->interposeFn = $fn; |
| 253 | 266 | } |