@@ -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 = true, $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); |
@@ -42,6 +42,7 @@ discard block |
||
42 | 42 | * @param $status |
43 | 43 | * @param $value |
44 | 44 | * @param $message |
45 | + * @param string $url |
|
45 | 46 | */ |
46 | 47 | public function __construct($status, $message = '', $value = null, $url = null) |
47 | 48 | { |
@@ -73,7 +74,7 @@ discard block |
||
73 | 74 | } |
74 | 75 | |
75 | 76 | /** |
76 | - * @param Attribute $attributes |
|
77 | + * @param Attribute $attribute |
|
77 | 78 | */ |
78 | 79 | public function addAttribute(Attribute $attribute) |
79 | 80 | { |
@@ -136,7 +137,7 @@ discard block |
||
136 | 137 | } |
137 | 138 | |
138 | 139 | /** |
139 | - * @param string $identifier |
|
140 | + * @param string $identifierRule |
|
140 | 141 | */ |
141 | 142 | public function setIdentifierRule($identifierRule) |
142 | 143 | { |