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