@@ -37,6 +37,7 @@ |
||
| 37 | 37 | |
| 38 | 38 | /** |
| 39 | 39 | * @param string |
| 40 | + * @param \Psr\Http\Message\StreamInterface $body |
|
| 40 | 41 | * @return array |
| 41 | 42 | */ |
| 42 | 43 | private function getLocations($body) { |
@@ -15,23 +15,23 @@ |
||
| 15 | 15 | |
| 16 | 16 | private function getSchema() |
| 17 | 17 | { |
| 18 | - return __DIR__ . '/' . self::SCHEMA; |
|
| 18 | + return __DIR__.'/'.self::SCHEMA; |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | - private function validateBody ($body) { |
|
| 21 | + private function validateBody($body) { |
|
| 22 | 22 | libxml_clear_errors(); |
| 23 | 23 | $dom = new \DOMDocument(); |
| 24 | 24 | @$dom->loadXML($body); |
| 25 | 25 | $lastError = libxml_get_last_error(); |
| 26 | 26 | if ($lastError) { |
| 27 | 27 | throw new ValidationFailedException( |
| 28 | - 'The given sitemap file is not well formed (last error: ' . str_replace("\n", '', $lastError->message) . ').'); |
|
| 28 | + 'The given sitemap file is not well formed (last error: '.str_replace("\n", '', $lastError->message).').'); |
|
| 29 | 29 | } |
| 30 | 30 | $valid = @$dom->schemaValidate($this->getSchema()); |
| 31 | 31 | if (!$valid) { |
| 32 | 32 | $lastError = libxml_get_last_error(); |
| 33 | 33 | throw new ValidationFailedException( |
| 34 | - 'The given sitemap file did not validate vs. sitemap.xsd (last error: ' . str_replace("\n", '', $lastError->message) . ').'); |
|
| 34 | + 'The given sitemap file did not validate vs. sitemap.xsd (last error: '.str_replace("\n", '', $lastError->message).').'); |
|
| 35 | 35 | } |
| 36 | 36 | } |
| 37 | 37 | |
@@ -47,8 +47,7 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | if (isset($xmlValues['sitemap']['loc'])) { |
| 49 | 49 | $locations[] = $xmlValues['sitemap']['loc']; |
| 50 | - } |
|
| 51 | - else { |
|
| 50 | + } else { |
|
| 52 | 51 | foreach ($xmlValues['sitemap'] AS $sitemap) { |
| 53 | 52 | $locations[] = $sitemap['loc']; |
| 54 | 53 | } |
@@ -70,8 +69,7 @@ discard block |
||
| 70 | 69 | $singleSitemapXml = file_get_contents($sitemapUrl); |
| 71 | 70 | $this->validateBody($singleSitemapXml); |
| 72 | 71 | } |
| 73 | - } |
|
| 74 | - elseif (preg_match('/<urlset/', $body)) { |
|
| 72 | + } elseif (preg_match('/<urlset/', $body)) { |
|
| 75 | 73 | $this->validateBody($body); |
| 76 | 74 | } |
| 77 | 75 | } |
@@ -13,12 +13,12 @@ |
||
| 13 | 13 | public function doValidation(Response $response) |
| 14 | 14 | { |
| 15 | 15 | $domDocument = new \DOMDocument(); |
| 16 | - $success = @$domDocument->loadXML((string) $response->getBody()); // true/false |
|
| 16 | + $success = @$domDocument->loadXML((string) $response->getBody()); // true/false |
|
| 17 | 17 | |
| 18 | 18 | $lastError = libxml_get_last_error(); |
| 19 | 19 | if (!$success || $lastError) { |
| 20 | - throw new \RuntimeException('The xml file '. $response->getUri() . ' is not well formed (last error: ' . |
|
| 21 | - str_replace("\n", '', $lastError->message) . ').'); |
|
| 20 | + throw new \RuntimeException('The xml file '.$response->getUri().' is not well formed (last error: '. |
|
| 21 | + str_replace("\n", '', $lastError->message).').'); |
|
| 22 | 22 | } |
| 23 | 23 | } |
| 24 | 24 | } |