@@ -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 | } |
@@ -23,12 +23,12 @@ discard block |
||
23 | 23 | |
24 | 24 | private function getSchema() |
25 | 25 | { |
26 | - return __DIR__ . '/' . self::SCHEMA; |
|
26 | + return __DIR__.'/'.self::SCHEMA; |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | public function doValidation(ResponseInterface $response) |
30 | 30 | { |
31 | - $body = (string)$response->getBody(); |
|
31 | + $body = (string) $response->getBody(); |
|
32 | 32 | |
33 | 33 | if (preg_match('/<rss/', $body)) { |
34 | 34 | libxml_clear_errors(); |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | |
39 | 39 | if ($lastError) { |
40 | 40 | throw new ValidationFailedException( |
41 | - 'The given xml file is not well formed (last error: ' . |
|
42 | - str_replace("\n", '', $lastError->message) . ').'); |
|
41 | + 'The given xml file is not well formed (last error: '. |
|
42 | + str_replace("\n", '', $lastError->message).').'); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | $valid = @$dom->schemaValidate($this->getSchema()); |
@@ -49,11 +49,11 @@ discard block |
||
49 | 49 | $lastErrorMessage = str_replace("\n", '', $lastError->message); |
50 | 50 | |
51 | 51 | if ($response instanceof UriAwareResponse) { |
52 | - $toolUrl = sprintf(self::PUBLIC_SERVICE, urlencode((string)$response->getUri())); |
|
52 | + $toolUrl = sprintf(self::PUBLIC_SERVICE, urlencode((string) $response->getUri())); |
|
53 | 53 | } else { |
54 | 54 | $toolUrl = ''; |
55 | 55 | } |
56 | - return new CheckResult(CheckResult::STATUS_FAILURE, 'The given xml file is not a valid rss file (last error: ' . $lastErrorMessage . ').', null, $toolUrl); |
|
56 | + return new CheckResult(CheckResult::STATUS_FAILURE, 'The given xml file is not a valid rss file (last error: '.$lastErrorMessage.').', null, $toolUrl); |
|
57 | 57 | } |
58 | 58 | } |
59 | 59 | return new CheckResult(CheckResult::STATUS_SUCCESS, 'The given rss file is valid.'); |
@@ -19,7 +19,7 @@ |
||
19 | 19 | */ |
20 | 20 | public function isFiltered(UriInterface $currentUri, UriInterface $startUri) |
21 | 21 | { |
22 | - return strlen((string)$currentUri) > 255; |
|
22 | + return strlen((string) $currentUri) > 255; |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | public function isResponseFiltered(ResponseInterface $response, UriInterface $startUri) |
@@ -4,8 +4,6 @@ |
||
4 | 4 | |
5 | 5 | use phm\HttpWebdriverClient\Http\Response\UriAwareResponse; |
6 | 6 | use Psr\Http\Message\ResponseInterface; |
7 | -use whm\Smoke\Http\ClientAware; |
|
8 | -use whm\Smoke\Http\Response; |
|
9 | 7 | use whm\Smoke\Rules\Rule; |
10 | 8 | use whm\Smoke\Rules\ValidationFailedException; |
11 | 9 |
@@ -21,12 +21,12 @@ discard block |
||
21 | 21 | public function validate(ResponseInterface $response) |
22 | 22 | { |
23 | 23 | if ($response instanceof UriAwareResponse) { |
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 |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | */ |
27 | 27 | protected function doValidation(ResponseInterface $response) |
28 | 28 | { |
29 | - $body = (string)$response->getBody(); |
|
29 | + $body = (string) $response->getBody(); |
|
30 | 30 | |
31 | 31 | $dom = new \DOMDocument(); |
32 | 32 | @$dom->loadXML($body); |
@@ -41,12 +41,12 @@ discard block |
||
41 | 41 | $error = true; |
42 | 42 | $lastError = libxml_get_last_error(); |
43 | 43 | |
44 | - $messageParts[] = $xsdFile['xsdfilename'] . ' - ' . $xsdFile['xsdfileurl'] . ' (last error: ' . str_replace("\n", '', $lastError->message) . ').'; |
|
44 | + $messageParts[] = $xsdFile['xsdfilename'].' - '.$xsdFile['xsdfileurl'].' (last error: '.str_replace("\n", '', $lastError->message).').'; |
|
45 | 45 | } |
46 | 46 | } |
47 | 47 | |
48 | 48 | if ($error === true) { |
49 | - $message = 'XML file (' . (string)$response->getUri() . ') does not validate against the following XSD files: ' . implode(', ', $messageParts); |
|
49 | + $message = 'XML file ('.(string) $response->getUri().') does not validate against the following XSD files: '.implode(', ', $messageParts); |
|
50 | 50 | throw new ValidationFailedException($message); |
51 | 51 | } |
52 | 52 | } |
@@ -103,7 +103,7 @@ |
||
103 | 103 | $result = new CheckResult(CheckResult::STATUS_SUCCESS, 'Check successful.'); |
104 | 104 | } |
105 | 105 | } catch (\Exception $e) { |
106 | - $result = new CheckResult(CheckResult::STATUS_FAILURE, 'An error occurred: ' . $e->getMessage()); |
|
106 | + $result = new CheckResult(CheckResult::STATUS_FAILURE, 'An error occurred: '.$e->getMessage()); |
|
107 | 107 | $this->eventDispatcher->simpleNotify('Scanner.CheckResponse.Rule.Error', array('checkResult' => $result, 'ruleName' => $name, 'exception' => $e)); |
108 | 108 | } |
109 | 109 |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | |
16 | 16 | private function getEndpoint(UriInterface $uri) |
17 | 17 | { |
18 | - return str_replace('#url#', urlencode((string)$uri), self::ENDPOINT); |
|
18 | + return str_replace('#url#', urlencode((string) $uri), self::ENDPOINT); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | public function validate(ResponseInterface $response) |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | ))); |
39 | 39 | |
40 | 40 | if (property_exists($result, 'error')) { |
41 | - $checkResult = new CheckResult(CheckResult::STATUS_FAILURE, 'Google mobile friendly test was not passed. Error "' . $result->error->message . '"'); |
|
41 | + $checkResult = new CheckResult(CheckResult::STATUS_FAILURE, 'Google mobile friendly test was not passed. Error "'.$result->error->message.'"'); |
|
42 | 42 | $checkResult->addAttribute(new Attribute('Google response', json_encode($result), true)); |
43 | 43 | return $checkResult; |
44 | 44 | } |
@@ -46,10 +46,10 @@ discard block |
||
46 | 46 | $passResult = $result->ruleGroups->USABILITY; |
47 | 47 | |
48 | 48 | if (!$passResult->pass) { |
49 | - $result = new CheckResult(CheckResult::STATUS_FAILURE, 'Google mobile friendly test was not passed. Score ' . $passResult->score . '/100.', (int)$passResult->score); |
|
49 | + $result = new CheckResult(CheckResult::STATUS_FAILURE, 'Google mobile friendly test was not passed. Score '.$passResult->score.'/100.', (int) $passResult->score); |
|
50 | 50 | |
51 | 51 | } else { |
52 | - $result = new CheckResult(CheckResult::STATUS_SUCCESS, 'Google mobile friendly test passed. Score ' . $passResult->score . '/100.', (int)$passResult->score); |
|
52 | + $result = new CheckResult(CheckResult::STATUS_SUCCESS, 'Google mobile friendly test passed. Score '.$passResult->score.'/100.', (int) $passResult->score); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | $result->addAttribute(new Attribute('google_result', json_encode($result), true)); |
@@ -21,7 +21,7 @@ |
||
21 | 21 | */ |
22 | 22 | public function init($nocache = false, $clientTimeout = 20000) |
23 | 23 | { |
24 | - $timeoutInSeconds = (int)($clientTimeout / 1000); |
|
24 | + $timeoutInSeconds = (int) ($clientTimeout / 1000); |
|
25 | 25 | |
26 | 26 | if ($nocache) { |
27 | 27 | $this->guzzleClient = new phmGuzzleClient(null, $timeoutInSeconds); |