| Conditions | 4 |
| Paths | 4 |
| Total Lines | 24 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 36 | public function __invoke(RequestInterface $request, ResponseInterface $response, callable $next) |
||
| 37 | { |
||
| 38 | if ($request->getUri()->getPath() === '/robots.txt') { |
||
| 39 | $response = $response->withHeader('Content-Type', 'text/plain'); |
||
| 40 | |||
| 41 | if ($this->allow) { |
||
| 42 | $response->getBody()->write("User-Agent: *\nAllow: /"); |
||
| 43 | |||
| 44 | return $response; |
||
| 45 | } |
||
| 46 | |||
| 47 | $response->getBody()->write("User-Agent: *\nDisallow: /"); |
||
| 48 | |||
| 49 | return $response; |
||
| 50 | } |
||
| 51 | |||
| 52 | $response = $next($request, $response); |
||
| 53 | |||
| 54 | if ($this->allow) { |
||
| 55 | return $response->withHeader(self::HEADER, 'index, follow'); |
||
| 56 | } |
||
| 57 | |||
| 58 | return $response->withHeader(self::HEADER, 'noindex, nofollow, noarchive'); |
||
| 59 | } |
||
| 60 | } |
||
| 61 |