@@ -31,12 +31,12 @@ discard block |
||
31 | 31 | |
32 | 32 | // @todo this could be part of an abstract class |
33 | 33 | if ($this->useDom) { |
34 | - $content = (string)$response->getBody(); |
|
34 | + $content = (string) $response->getBody(); |
|
35 | 35 | } else { |
36 | 36 | if ($response instanceof DomAwareResponse) { |
37 | 37 | $content = $response->getHtmlBody(); |
38 | 38 | } else { |
39 | - $content = (string)$response->getBody(); |
|
39 | + $content = (string) $response->getBody(); |
|
40 | 40 | } |
41 | 41 | } |
42 | 42 | |
@@ -48,16 +48,16 @@ discard block |
||
48 | 48 | $count = $domXPath->query($xpath['pattern'])->length; |
49 | 49 | |
50 | 50 | if ($xpath['relation'] === 'equals') { |
51 | - $result = $count === (int)$xpath['value']; |
|
52 | - $message = 'The xpath "' . $xpath['pattern'] . '" was found ' . $count . ' times. Expected were exact ' . $xpath['value'] . ' occurencies.'; |
|
51 | + $result = $count === (int) $xpath['value']; |
|
52 | + $message = 'The xpath "'.$xpath['pattern'].'" was found '.$count.' times. Expected were exact '.$xpath['value'].' occurencies.'; |
|
53 | 53 | } elseif ($xpath['relation'] === 'less than') { |
54 | - $result = $count < (int)$xpath['value']; |
|
55 | - $message = 'The xpath "' . $xpath['pattern'] . '" was found ' . $count . ' times. Expected were less than ' . $xpath['value'] . '.'; |
|
54 | + $result = $count < (int) $xpath['value']; |
|
55 | + $message = 'The xpath "'.$xpath['pattern'].'" was found '.$count.' times. Expected were less than '.$xpath['value'].'.'; |
|
56 | 56 | } elseif ($xpath['relation'] === 'greater than') { |
57 | - $result = $count > (int)$xpath['value']; |
|
58 | - $message = 'The xpath "' . $xpath['pattern'] . '" was found ' . $count . ' times. Expected were more than ' . $xpath['value'] . '.'; |
|
57 | + $result = $count > (int) $xpath['value']; |
|
58 | + $message = 'The xpath "'.$xpath['pattern'].'" was found '.$count.' times. Expected were more than '.$xpath['value'].'.'; |
|
59 | 59 | } else { |
60 | - throw new \RuntimeException('Relation not defined. Given "' . $xpath['relation'] . '" expected [equals, greater than, less than]'); |
|
60 | + throw new \RuntimeException('Relation not defined. Given "'.$xpath['relation'].'" expected [equals, greater than, less than]'); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | $this->assert($result, $message); |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | |
15 | 15 | private function getEndpoint(UriInterface $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 | } |
@@ -29,14 +29,14 @@ |
||
29 | 29 | if ($response->getDuration() > $this->maxDuration) { |
30 | 30 | return new CheckResult( |
31 | 31 | CheckResult::STATUS_FAILURE, |
32 | - 'The http request took ' . (int)$response->getDuration() . ' milliseconds (limit was ' . $this->maxDuration . 'ms).', |
|
33 | - (int)$response->getDuration()); |
|
32 | + 'The http request took '.(int) $response->getDuration().' milliseconds (limit was '.$this->maxDuration.'ms).', |
|
33 | + (int) $response->getDuration()); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | return new CheckResult( |
37 | 37 | CheckResult::STATUS_SUCCESS, |
38 | - 'The http request took ' . (int)$response->getDuration() . ' milliseconds (limit was ' . $this->maxDuration . 'ms).', |
|
39 | - (int)$response->getDuration()); |
|
38 | + 'The http request took '.(int) $response->getDuration().' milliseconds (limit was '.$this->maxDuration.'ms).', |
|
39 | + (int) $response->getDuration()); |
|
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 | |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | if (!$valid) { |
57 | 57 | $lastError = libxml_get_last_error(); |
58 | 58 | throw new ValidationFailedException( |
59 | - 'The given sitemap file (' . $filename . ') did not validate against the sitemap schema (last error: ' . str_replace("\n", '', $lastError->message) . ').'); |
|
59 | + 'The given sitemap file ('.$filename.') did not validate against the sitemap schema (last error: '.str_replace("\n", '', $lastError->message).').'); |
|
60 | 60 | } |
61 | 61 | } |
62 | 62 | |
@@ -67,16 +67,16 @@ discard block |
||
67 | 67 | protected function doValidation(ResponseInterface $response) |
68 | 68 | { |
69 | 69 | if ($response instanceof DomAwareResponse) { |
70 | - $body = (string)$response->getHtmlBody(); |
|
70 | + $body = (string) $response->getHtmlBody(); |
|
71 | 71 | } else { |
72 | - $body = (string)$response->getBody(); |
|
72 | + $body = (string) $response->getBody(); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | // sitemapindex or urlset |
76 | 76 | if (preg_match('/<sitemapindex/', $body)) { |
77 | - $this->validateBody($body, (string)$response->getUri()); |
|
77 | + $this->validateBody($body, (string) $response->getUri()); |
|
78 | 78 | } elseif (preg_match('/<urlset/', $body)) { |
79 | - $this->validateBody($body, (string)$response->getUri(), false); |
|
79 | + $this->validateBody($body, (string) $response->getUri(), false); |
|
80 | 80 | } |
81 | 81 | } |
82 | 82 | } |
@@ -24,9 +24,9 @@ discard block |
||
24 | 24 | public function doValidation(ResponseInterface $response) |
25 | 25 | { |
26 | 26 | if ($response instanceof DomAwareResponse) { |
27 | - $body = (string)$response->getHtmlBody(); |
|
27 | + $body = (string) $response->getHtmlBody(); |
|
28 | 28 | } else { |
29 | - $body = (string)$response->getBody(); |
|
29 | + $body = (string) $response->getBody(); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | if ($body == "") { |
@@ -45,8 +45,8 @@ discard block |
||
45 | 45 | $lastError = libxml_get_last_error(); |
46 | 46 | |
47 | 47 | if ($lastError) { |
48 | - throw new ValidationFailedException('The xml file ' . $response->getUri() . ' is not well formed (last error: ' . |
|
49 | - str_replace("\n", '', $lastError->message) . ').'); |
|
48 | + throw new ValidationFailedException('The xml file '.$response->getUri().' is not well formed (last error: '. |
|
49 | + str_replace("\n", '', $lastError->message).').'); |
|
50 | 50 | } else { |
51 | 51 | return new CheckResult(CheckResult::STATUS_FAILURE, 'Unknown error occured.'); |
52 | 52 | } |
@@ -18,22 +18,22 @@ |
||
18 | 18 | */ |
19 | 19 | protected function doValidation(ResponseInterface $response) |
20 | 20 | { |
21 | - $document = new Document((string)$response->getBody(), false); |
|
21 | + $document = new Document((string) $response->getBody(), false); |
|
22 | 22 | $urls = $document->getDependencies($response->getUri()); |
23 | 23 | $invalidUrls = array(); |
24 | 24 | |
25 | 25 | foreach ($urls as $url) { |
26 | 26 | if (function_exists('idn_to_ascii')) { |
27 | - $idnUrl = $url->getScheme() . '://' . idn_to_ascii($url->getHost()) . $url->getPath(); |
|
27 | + $idnUrl = $url->getScheme().'://'.idn_to_ascii($url->getHost()).$url->getPath(); |
|
28 | 28 | } else { |
29 | - $idnUrl = $url->getScheme() . '://' . $url->getHost() . $url->getPath(); |
|
29 | + $idnUrl = $url->getScheme().'://'.$url->getHost().$url->getPath(); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | if (!filter_var($idnUrl, FILTER_VALIDATE_URL)) { |
33 | - $invalidUrls[] = (string)$url; |
|
33 | + $invalidUrls[] = (string) $url; |
|
34 | 34 | } |
35 | 35 | } |
36 | 36 | |
37 | - $this->assert(count($invalidUrls) === 0, 'Invalid urls found (' . implode(', ', $invalidUrls) . ').'); |
|
37 | + $this->assert(count($invalidUrls) === 0, 'Invalid urls found ('.implode(', ', $invalidUrls).').'); |
|
38 | 38 | } |
39 | 39 | } |
@@ -48,13 +48,13 @@ discard block |
||
48 | 48 | protected function writeSmokeCredentials($url = null) |
49 | 49 | { |
50 | 50 | if (defined('SMOKE_CREDENTIALS')) { |
51 | - $this->output->writeln("\n " . SMOKE_CREDENTIALS . "\n"); |
|
51 | + $this->output->writeln("\n ".SMOKE_CREDENTIALS."\n"); |
|
52 | 52 | } else { |
53 | - $this->output->writeln("\n Smoke " . SMOKE_VERSION . " by Nils Langner\n"); |
|
53 | + $this->output->writeln("\n Smoke ".SMOKE_VERSION." by Nils Langner\n"); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | if ($url) { |
57 | - $this->output->writeln(' <info>Scanning ' . $url . "</info>\n"); |
|
57 | + $this->output->writeln(' <info>Scanning '.$url."</info>\n"); |
|
58 | 58 | } |
59 | 59 | } |
60 | 60 | |
@@ -101,12 +101,12 @@ discard block |
||
101 | 101 | if ($configFile) { |
102 | 102 | if (strpos($configFile, 'http://') === 0 || strpos($configFile, 'https://') === 0) { |
103 | 103 | $curlClient = new Client(); |
104 | - $fileContent = (string)$curlClient->get($configFile)->getBody(); |
|
104 | + $fileContent = (string) $curlClient->get($configFile)->getBody(); |
|
105 | 105 | } else { |
106 | 106 | if (file_exists($configFile)) { |
107 | 107 | $fileContent = file_get_contents($configFile); |
108 | 108 | } else { |
109 | - throw new \RuntimeException("Config file was not found ('" . $configFile . "')."); |
|
109 | + throw new \RuntimeException("Config file was not found ('".$configFile."')."); |
|
110 | 110 | } |
111 | 111 | } |
112 | 112 | $configArray = EnvAwareYaml::parse($fileContent); |
@@ -15,9 +15,9 @@ |
||
15 | 15 | public function isFiltered(UriInterface $uri, UriInterface $startPage) |
16 | 16 | { |
17 | 17 | foreach ($this->whitelist as $whitelist) { |
18 | - if (preg_match($whitelist, (string)$uri)) { |
|
18 | + if (preg_match($whitelist, (string) $uri)) { |
|
19 | 19 | foreach ($this->blacklist as $blacklist) { |
20 | - if (preg_match($blacklist, (string)$uri)) { |
|
20 | + if (preg_match($blacklist, (string) $uri)) { |
|
21 | 21 | return true; |
22 | 22 | } |
23 | 23 | } |
@@ -28,30 +28,30 @@ discard block |
||
28 | 28 | $client = new GuzzleClient(); |
29 | 29 | $errors = []; |
30 | 30 | |
31 | - $targetUrl = (string)$this->removeCredentials($response->getUri()); |
|
31 | + $targetUrl = (string) $this->removeCredentials($response->getUri()); |
|
32 | 32 | |
33 | 33 | |
34 | 34 | foreach ($this->urls as $url) { |
35 | 35 | $uri = new Uri($url['url']); |
36 | 36 | |
37 | 37 | $urlResponses = $client->sendRequests([new Request('GET', $uri)]); |
38 | - $effectiveUrl = (string)$urlResponses[0]->getEffectiveUri(); |
|
38 | + $effectiveUrl = (string) $urlResponses[0]->getEffectiveUri(); |
|
39 | 39 | |
40 | 40 | if ($effectiveUrl != $targetUrl) { |
41 | - $errors[] = 'The url "' . $url['url'] . '" gets redirected to "' . $effectiveUrl . '".'; |
|
41 | + $errors[] = 'The url "'.$url['url'].'" gets redirected to "'.$effectiveUrl.'".'; |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 | |
45 | 45 | if (count($errors) > 0) { |
46 | - $message = 'Not all given urls do redirect to "' . $targetUrl . '"".<ul>'; |
|
46 | + $message = 'Not all given urls do redirect to "'.$targetUrl.'"".<ul>'; |
|
47 | 47 | foreach ($errors as $error) { |
48 | - $message .= '<li>' . $error . '</li>'; |
|
48 | + $message .= '<li>'.$error.'</li>'; |
|
49 | 49 | } |
50 | 50 | $message .= "</ul>"; |
51 | 51 | |
52 | 52 | return new CheckResult(CheckResult::STATUS_FAILURE, $message); |
53 | 53 | } else { |
54 | - return new CheckResult(CheckResult::STATUS_SUCCESS, 'All given urls redirect to ' . (string)$response->getUri()); |
|
54 | + return new CheckResult(CheckResult::STATUS_SUCCESS, 'All given urls redirect to '.(string) $response->getUri()); |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | |
@@ -59,10 +59,10 @@ discard block |
||
59 | 59 | { |
60 | 60 | $query = ''; |
61 | 61 | if ($uri->getQuery()) { |
62 | - $query = "?" . $uri->getQuery(); |
|
62 | + $query = "?".$uri->getQuery(); |
|
63 | 63 | } |
64 | 64 | |
65 | - $plainUri = $uri->getScheme() . '://' . $uri->getHost() . $uri->getPath() . $query; |
|
65 | + $plainUri = $uri->getScheme().'://'.$uri->getHost().$uri->getPath().$query; |
|
66 | 66 | |
67 | 67 | return new Uri($plainUri); |
68 | 68 | } |