@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | public function doValidation(ResponseInterface $response) |
23 | 23 | { |
24 | 24 | $domDocument = new \DOMDocument(); |
25 | - @$domDocument->loadHTML((string)$response->getBody()); |
|
25 | + @$domDocument->loadHTML((string) $response->getBody()); |
|
26 | 26 | |
27 | 27 | $domXPath = new \DOMXPath($domDocument); |
28 | 28 | |
@@ -30,16 +30,16 @@ discard block |
||
30 | 30 | $count = $domXPath->query($xpath['pattern'])->length; |
31 | 31 | |
32 | 32 | if ($xpath['relation'] === 'equals') { |
33 | - $result = $count === (int)$xpath['value']; |
|
34 | - $message = 'The xpath "' . $xpath['pattern'] . '" was found ' . $count . ' times. Expected were exact ' . $xpath['value'] . ' occurencies.'; |
|
33 | + $result = $count === (int) $xpath['value']; |
|
34 | + $message = 'The xpath "'.$xpath['pattern'].'" was found '.$count.' times. Expected were exact '.$xpath['value'].' occurencies.'; |
|
35 | 35 | } elseif ($xpath['relation'] === 'less than') { |
36 | - $result = $count < (int)$xpath['value']; |
|
37 | - $message = 'The xpath "' . $xpath['pattern'] . '" was found ' . $count . ' times. Expected were less than ' . $xpath['value'] . '.'; |
|
36 | + $result = $count < (int) $xpath['value']; |
|
37 | + $message = 'The xpath "'.$xpath['pattern'].'" was found '.$count.' times. Expected were less than '.$xpath['value'].'.'; |
|
38 | 38 | } elseif ($xpath['relation'] === 'greater than') { |
39 | - $result = $count > (int)$xpath['value']; |
|
40 | - $message = 'The xpath "' . $xpath['pattern'] . '" was found ' . $count . ' times. Expected were more than ' . $xpath['value'] . '.'; |
|
39 | + $result = $count > (int) $xpath['value']; |
|
40 | + $message = 'The xpath "'.$xpath['pattern'].'" was found '.$count.' times. Expected were more than '.$xpath['value'].'.'; |
|
41 | 41 | } else { |
42 | - throw new \RuntimeException('Relation not defined. Given "' . $xpath['relation'] . '" expected [equals, greater than, less than]'); |
|
42 | + throw new \RuntimeException('Relation not defined. Given "'.$xpath['relation'].'" expected [equals, greater than, less than]'); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | $this->assert($result, $message); |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | public function doValidation(ResponseInterface $response) |
25 | 25 | { |
26 | 26 | $domDocument = new \DOMDocument(); |
27 | - @$domDocument->loadHTML((string)$response->getBody()); |
|
27 | + @$domDocument->loadHTML((string) $response->getBody()); |
|
28 | 28 | |
29 | 29 | $domXPath = new \DOMXPath($domDocument); |
30 | 30 | |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | try { |
38 | 38 | $selectorAsXPath = $converter->toXPath($selector['pattern']); |
39 | 39 | } catch (\Exception $e) { |
40 | - throw new ValidationFailedException('Invalid css selector (' . $selector['pattern'] . ').'); |
|
40 | + throw new ValidationFailedException('Invalid css selector ('.$selector['pattern'].').'); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | $count = $domXPath->query($selectorAsXPath)->length; |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | if ($error === true) { |
52 | 52 | $allNotFoundSelectors = implode('", "', $snotFoundSelectors); |
53 | 53 | |
54 | - throw new ValidationFailedException('CSS Selector "' . $allNotFoundSelectors . '" not found in DOM.'); |
|
54 | + throw new ValidationFailedException('CSS Selector "'.$allNotFoundSelectors.'" not found in DOM.'); |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | } |
@@ -21,12 +21,12 @@ discard block |
||
21 | 21 | |
22 | 22 | public function validate(ResponseInterface $response) |
23 | 23 | { |
24 | - $url = $response->getUri()->getScheme() . '://' . $response->getUri()->getHost(); |
|
24 | + $url = $response->getUri()->getScheme().'://'.$response->getUri()->getHost(); |
|
25 | 25 | |
26 | 26 | if (substr_count($url, '/') === 2) { |
27 | - $filename = $robotsUrl = $url . '/robots.txt'; |
|
27 | + $filename = $robotsUrl = $url.'/robots.txt'; |
|
28 | 28 | } elseif (substr_count($url, '/') === 3) { |
29 | - $filename = $robotsUrl = $url . 'robots.txt'; |
|
29 | + $filename = $robotsUrl = $url.'robots.txt'; |
|
30 | 30 | } else { |
31 | 31 | return; |
32 | 32 | } |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | |
40 | 40 | $normalizedContent = $this->normalizeContent($content); |
41 | 41 | |
42 | - if (strpos($normalizedContent, 'user-agent:* disallow:/' . PHP_EOL) !== false) { |
|
42 | + if (strpos($normalizedContent, 'user-agent:* disallow:/'.PHP_EOL) !== false) { |
|
43 | 43 | throw new ValidationFailedException('The robots.txt contains disallow all (Disallow: /)'); |
44 | 44 | } |
45 | 45 |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | |
15 | 15 | private function getEndpoint(Uri $uri) |
16 | 16 | { |
17 | - return str_replace('#url#', urlencode((string)$uri), self::ENDPOINT); |
|
17 | + return str_replace('#url#', urlencode((string) $uri), self::ENDPOINT); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | public function validate(ResponseInterface $response) |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | ))); |
34 | 34 | |
35 | 35 | if (property_exists($result, 'error')) { |
36 | - $checkResult = new CheckResult(CheckResult::STATUS_FAILURE, 'Google mobile friendly test was not passed. Error "' . $result->error->message . '"'); |
|
36 | + $checkResult = new CheckResult(CheckResult::STATUS_FAILURE, 'Google mobile friendly test was not passed. Error "'.$result->error->message.'"'); |
|
37 | 37 | $checkResult->addAttribute(new Attribute('Google response', json_encode($result), true)); |
38 | 38 | return $checkResult; |
39 | 39 | } |
@@ -41,9 +41,9 @@ discard block |
||
41 | 41 | $passResult = $result->ruleGroups->USABILITY; |
42 | 42 | |
43 | 43 | if (!$passResult->pass) { |
44 | - return new CheckResult(CheckResult::STATUS_FAILURE, 'Google mobile friendly test was not passed. Score ' . $passResult->score . '/100.', (int)$passResult->score); |
|
44 | + return new CheckResult(CheckResult::STATUS_FAILURE, 'Google mobile friendly test was not passed. Score '.$passResult->score.'/100.', (int) $passResult->score); |
|
45 | 45 | } |
46 | 46 | |
47 | - return new CheckResult(CheckResult::STATUS_SUCCESS, 'Google mobile friendly test passed. Score ' . $passResult->score . '/100.', (int)$passResult->score); |
|
47 | + return new CheckResult(CheckResult::STATUS_SUCCESS, 'Google mobile friendly test passed. Score '.$passResult->score.'/100.', (int) $passResult->score); |
|
48 | 48 | } |
49 | 49 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | private function initConfigArray(array $configArray, array $defaultSettings = null) |
66 | 66 | { |
67 | 67 | if ($defaultSettings === null) { |
68 | - $defaultSettings = Yaml::parse(file_get_contents(__DIR__ . '/../settings/' . self::DEFAULT_SETTINGS)); |
|
68 | + $defaultSettings = Yaml::parse(file_get_contents(__DIR__.'/../settings/'.self::DEFAULT_SETTINGS)); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | if (count($configArray) === 0) { |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | if ($this->hasSection($section)) { |
168 | 168 | return $this->configArray[$section]; |
169 | 169 | } else { |
170 | - throw new \RuntimeException('The section (' . $section . ') you are trying to access does not exist.'); |
|
170 | + throw new \RuntimeException('The section ('.$section.') you are trying to access does not exist.'); |
|
171 | 171 | } |
172 | 172 | } |
173 | 173 | |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | if (array_key_exists($name, $this->extensions)) { |
177 | 177 | return $this->extensions[$name]; |
178 | 178 | } else { |
179 | - throw new \RuntimeException('The extension ("' . $name . '") you are trying to access does not exist. Registered extensions are: ' . implode(' ,', array_keys($this->extensions)) . '.'); |
|
179 | + throw new \RuntimeException('The extension ("'.$name.'") you are trying to access does not exist. Registered extensions are: '.implode(' ,', array_keys($this->extensions)).'.'); |
|
180 | 180 | } |
181 | 181 | } |
182 | 182 | |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | try { |
202 | 202 | $client = Init::initialize($this->configArray['client']); |
203 | 203 | } catch (\Exception $e) { |
204 | - throw new ConfigurationException('Error initializing client (' . $e->getMessage() . ')'); |
|
204 | + throw new ConfigurationException('Error initializing client ('.$e->getMessage().')'); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | if (array_key_exists('cache', $this->configArray['client'])) { |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | return; |
19 | 19 | } |
20 | 20 | |
21 | - $crawler = new Crawler((string)$response->getBody()); |
|
21 | + $crawler = new Crawler((string) $response->getBody()); |
|
22 | 22 | |
23 | 23 | $idList = $crawler->filterXPath('//*[@id!=""]'); |
24 | 24 | |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | |
37 | 37 | if (count($duplicatedIds) > 0) { |
38 | 38 | unset($duplicatedIds['']); |
39 | - throw new ValidationFailedException('Duplicate ids found (' . implode(', ', array_keys($duplicatedIds)) . ')'); |
|
39 | + throw new ValidationFailedException('Duplicate ids found ('.implode(', ', array_keys($duplicatedIds)).')'); |
|
40 | 40 | } |
41 | 41 | } |
42 | 42 | } |
@@ -30,13 +30,13 @@ discard block |
||
30 | 30 | private function getSchema($isIndex) |
31 | 31 | { |
32 | 32 | if ($isIndex) { |
33 | - return __DIR__ . '/' . self::INDEX; |
|
33 | + return __DIR__.'/'.self::INDEX; |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | if ($this->strictMode) { |
37 | - return __DIR__ . '/' . self::SCHEMA; |
|
37 | + return __DIR__.'/'.self::SCHEMA; |
|
38 | 38 | } else { |
39 | - return __DIR__ . '/' . self::NON_STRICT_SCHEMA; |
|
39 | + return __DIR__.'/'.self::NON_STRICT_SCHEMA; |
|
40 | 40 | } |
41 | 41 | } |
42 | 42 | |
@@ -50,19 +50,19 @@ discard block |
||
50 | 50 | if (!$valid) { |
51 | 51 | $lastError = libxml_get_last_error(); |
52 | 52 | throw new ValidationFailedException( |
53 | - 'The given sitemap file (' . $filename . ') did not validate against the sitemap schema (last error: ' . str_replace("\n", '', $lastError->message) . ').'); |
|
53 | + 'The given sitemap file ('.$filename.') did not validate against the sitemap schema (last error: '.str_replace("\n", '', $lastError->message).').'); |
|
54 | 54 | } |
55 | 55 | } |
56 | 56 | |
57 | 57 | protected function doValidation(ResponseInterface $response) |
58 | 58 | { |
59 | - $body = (string)$response->getBody(); |
|
59 | + $body = (string) $response->getBody(); |
|
60 | 60 | |
61 | 61 | // sitemapindex or urlset |
62 | 62 | if (preg_match('/<sitemapindex/', $body)) { |
63 | - $this->validateBody($body, (string)$response->getUri()); |
|
63 | + $this->validateBody($body, (string) $response->getUri()); |
|
64 | 64 | } elseif (preg_match('/<urlset/', $body)) { |
65 | - $this->validateBody($body, (string)$response->getUri(), false); |
|
65 | + $this->validateBody($body, (string) $response->getUri(), false); |
|
66 | 66 | } |
67 | 67 | } |
68 | 68 | } |
@@ -26,9 +26,9 @@ |
||
26 | 26 | |
27 | 27 | public function doValidation(ResponseInterface $response) |
28 | 28 | { |
29 | - $result = json_decode((string)$response->getBody()); |
|
29 | + $result = json_decode((string) $response->getBody()); |
|
30 | 30 | if ($result === null) { |
31 | - throw new ValidationFailedException("The given JSON data can not be validated (last error: '" . $this->json_errors[json_last_error()] . "')."); |
|
31 | + throw new ValidationFailedException("The given JSON data can not be validated (last error: '".$this->json_errors[json_last_error()]."')."); |
|
32 | 32 | } |
33 | 33 | } |
34 | 34 | } |
@@ -33,9 +33,9 @@ discard block |
||
33 | 33 | |
34 | 34 | protected function doValidation(ResponseInterface $response) |
35 | 35 | { |
36 | - $data = json_decode((string)$response->getBody()); |
|
36 | + $data = json_decode((string) $response->getBody()); |
|
37 | 37 | if ($data === null) { |
38 | - throw new ValidationFailedException("The given JSON data can not be validated (last error: '" . $this->json_errors[json_last_error()] . "')."); |
|
38 | + throw new ValidationFailedException("The given JSON data can not be validated (last error: '".$this->json_errors[json_last_error()]."')."); |
|
39 | 39 | } else { |
40 | 40 | $errorStatus = false; |
41 | 41 | $messageParts = array(); |
@@ -51,14 +51,14 @@ discard block |
||
51 | 51 | $errorStatus = true; |
52 | 52 | $errorMessage = ''; |
53 | 53 | foreach ($validator->getErrors() as $error) { |
54 | - $errorMessage = $errorMessage . sprintf("[%s] %s\n", $error['property'], $error['message']); |
|
54 | + $errorMessage = $errorMessage.sprintf("[%s] %s\n", $error['property'], $error['message']); |
|
55 | 55 | } |
56 | - $messageParts[] = $jsonSchemaFile['jsonfilename'] . ' - ' . $jsonSchemaFile['jsonfileurl'] . '(last error: ' . $errorMessage . ').'; |
|
56 | + $messageParts[] = $jsonSchemaFile['jsonfilename'].' - '.$jsonSchemaFile['jsonfileurl'].'(last error: '.$errorMessage.').'; |
|
57 | 57 | } |
58 | 58 | } |
59 | 59 | |
60 | 60 | if ($errorStatus === true) { |
61 | - $message = 'JSON file (' . (string) $response->getUri() . ') does not validate against the following JSON Schema files: ' . implode(', ', $messageParts); |
|
61 | + $message = 'JSON file ('.(string) $response->getUri().') does not validate against the following JSON Schema files: '.implode(', ', $messageParts); |
|
62 | 62 | throw new ValidationFailedException($message); |
63 | 63 | } |
64 | 64 | } |