| Conditions | 6 |
| Paths | 6 |
| Total Lines | 27 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 13 |
| CRAP Score | 6.0131 |
| Changes | 0 | ||
| 1 | <?php |
||
| 27 | 4 | public function run(string $middlewareServiceName = null) : bool |
|
| 28 | {
|
||
| 29 | |||
| 30 | 4 | if( !isset($this['request']) ) {
|
|
| 31 | 1 | throw new InvalidArgumentException('request service must be defined');
|
|
| 32 | } |
||
| 33 | 3 | $request = $this['request']; |
|
| 34 | |||
| 35 | 3 | if( !($request instanceof ServerRequestInterface) ) {
|
|
| 36 | 1 | throw new InvalidArgumentException('request is not an http server request');
|
|
| 37 | } |
||
| 38 | |||
| 39 | // auto service registration |
||
| 40 | 2 | if( $middlewareServiceName ) {
|
|
| 41 | 2 | $this->registerAsMiddleware($middlewareServiceName); |
|
| 42 | } |
||
| 43 | |||
| 44 | 2 | $response = $this->boot()->handle($request); |
|
| 45 | 2 | $response = $this->handleResponse($response); |
|
| 46 | |||
| 47 | 2 | if( isset($this['responseEmitter']) && is_callable($this['responseEmitter'])) {
|
|
| 48 | 2 | call_user_func($this['responseEmitter'],$response); |
|
| 49 | } else {
|
||
| 50 | var_dump($response); |
||
|
1 ignored issue
–
show
|
|||
| 51 | } |
||
| 52 | |||
| 53 | 2 | return true; |
|
| 54 | } |
||
| 56 | } |