| Conditions | 5 |
| Paths | 3 |
| Total Lines | 24 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 17 | public function getRobotsTxt() |
||
| 18 | { |
||
| 19 | if (null === $this->robotsTxt) { |
||
| 20 | $url = $this->getDomainAndScheme().'/robots.txt'; |
||
|
|
|||
| 21 | |||
| 22 | $request = new CurlRequest($url); |
||
| 23 | $request |
||
| 24 | ->setDefaultSpeedOptions() |
||
| 25 | ->setDownloadOnly('0-500000') |
||
| 26 | ->setUserAgent($this->getResponse()->getRequest()->getUserAgent()) |
||
| 27 | ; |
||
| 28 | $result = $request->exec(); |
||
| 29 | |||
| 30 | if (!$result instanceof \PiedWeb\Curl\Response |
||
| 31 | || false === stripos($result->getContentType(), 'text/plain') |
||
| 32 | || empty(trim($result->getContent())) |
||
| 33 | ) { |
||
| 34 | $this->robotsTxt = ''; |
||
| 35 | } else { |
||
| 36 | $this->robotsTxt = new RobotsTxt($result->getContent()); |
||
| 37 | } |
||
| 38 | } |
||
| 39 | |||
| 40 | return $this->robotsTxt; |
||
| 41 | } |
||
| 55 |