| Conditions | 3 |
| Paths | 4 |
| Total Lines | 28 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 41 | public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface |
||
| 42 | { |
||
| 43 | $response = $handler->handle($request); |
||
| 44 | |||
| 45 | // see: https://github.com/jshannon63/laravel-psr15-middleware/blob/master/src/exampleMiddleware.php |
||
| 46 | $response->getBody()->rewind(); |
||
| 47 | $body = $response->getBody(); |
||
| 48 | $contents = $body->getContents(); |
||
| 49 | |||
| 50 | if (static::MODE_PREPEND == $this->mode) { |
||
| 51 | $contents = str_replace( |
||
| 52 | '<body>', |
||
| 53 | "<body>".$this->string, |
||
| 54 | $contents |
||
| 55 | ); |
||
| 56 | } |
||
| 57 | if (static::MODE_APPEND == $this->mode) { |
||
| 58 | $contents = str_replace( |
||
| 59 | '</body>', |
||
| 60 | $this->string.'</body>', |
||
| 61 | $contents |
||
| 62 | ); |
||
| 63 | } |
||
| 64 | |||
| 65 | $body->rewind(); |
||
| 66 | $body->write($contents); |
||
| 67 | |||
| 68 | return $response->withBody($body); |
||
| 69 | } |
||
| 71 |