@@ -4,7 +4,6 @@ |
||
4 | 4 | |
5 | 5 | use Psr\Http\Message\ResponseInterface; |
6 | 6 | use whm\Html\Document; |
7 | -use whm\Smoke\Http\Response; |
|
8 | 7 | |
9 | 8 | /** |
10 | 9 | * This rules counts the js files that are included in a document. If the number is higher |
@@ -3,7 +3,6 @@ |
||
3 | 3 | namespace whm\Smoke\Rules\Image; |
4 | 4 | |
5 | 5 | use Psr\Http\Message\ResponseInterface; |
6 | -use whm\Smoke\Http\Response; |
|
7 | 6 | use whm\Smoke\Rules\StandardRule; |
8 | 7 | |
9 | 8 | /** |
@@ -30,8 +30,8 @@ |
||
30 | 30 | return; |
31 | 31 | } |
32 | 32 | |
33 | - $imageHash = md5((string)$response->getBody()); |
|
33 | + $imageHash = md5((string) $response->getBody()); |
|
34 | 34 | |
35 | - $this->assert(!array_key_exists($imageHash, $this->favicons), 'Seems like you use the standard favicon of your framework (' . $this->favicons[$imageHash] . ').'); |
|
35 | + $this->assert(!array_key_exists($imageHash, $this->favicons), 'Seems like you use the standard favicon of your framework ('.$this->favicons[$imageHash].').'); |
|
36 | 36 | } |
37 | 37 | } |
@@ -4,7 +4,6 @@ |
||
4 | 4 | |
5 | 5 | use JsonSchema\Validator; |
6 | 6 | use Psr\Http\Message\ResponseInterface; |
7 | -use whm\Smoke\Http\Response; |
|
8 | 7 | use whm\Smoke\Rules\StandardRule; |
9 | 8 | use whm\Smoke\Rules\ValidationFailedException; |
10 | 9 |
@@ -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 | } |
@@ -4,8 +4,6 @@ |
||
4 | 4 | |
5 | 5 | use Psr\Http\Message\ResponseInterface; |
6 | 6 | use Symfony\Component\DomCrawler\Crawler; |
7 | -use whm\Smoke\Http\Response; |
|
8 | -use whm\Smoke\Rules\Rule; |
|
9 | 7 | use whm\Smoke\Rules\StandardRule; |
10 | 8 | |
11 | 9 | /** |
@@ -19,10 +19,10 @@ discard block |
||
19 | 19 | |
20 | 20 | protected function doValidation(ResponseInterface $response) |
21 | 21 | { |
22 | - $crawler = new Crawler((string)$response->getBody()); |
|
22 | + $crawler = new Crawler((string) $response->getBody()); |
|
23 | 23 | $actionNodes = $crawler->filterXPath('//form[//input[@type="password"]]'); |
24 | 24 | |
25 | - $url = (string)$response->getUri(); |
|
25 | + $url = (string) $response->getUri(); |
|
26 | 26 | |
27 | 27 | foreach ($actionNodes as $node) { |
28 | 28 | $action = $node->getAttribute('action'); |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | |
37 | 37 | while ($parent = $parent->parentNode) { |
38 | 38 | if (property_exists($parent, 'tagName')) { |
39 | - $fullPath = $parent->tagName . '/' . $fullPath; |
|
39 | + $fullPath = $parent->tagName.'/'.$fullPath; |
|
40 | 40 | } else { |
41 | 41 | break; |
42 | 42 | } |
@@ -3,7 +3,6 @@ |
||
3 | 3 | namespace whm\Smoke\Rules\Seo; |
4 | 4 | |
5 | 5 | use Psr\Http\Message\ResponseInterface; |
6 | -use whm\Smoke\Http\Response; |
|
7 | 6 | use whm\Smoke\Rules\Rule; |
8 | 7 | use whm\Smoke\Rules\ValidationFailedException; |
9 | 8 |
@@ -4,8 +4,6 @@ |
||
4 | 4 | |
5 | 5 | use Ivory\HttpAdapter\HttpAdapterInterface; |
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 | |
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 |
@@ -28,6 +28,10 @@ |
||
28 | 28 | |
29 | 29 | abstract protected function doValidation(ResponseInterface $response); |
30 | 30 | |
31 | + /** |
|
32 | + * @param boolean $valueToBeTrue |
|
33 | + * @param string $errorMessage |
|
34 | + */ |
|
31 | 35 | protected function assert($valueToBeTrue, $errorMessage) |
32 | 36 | { |
33 | 37 | if (!$valueToBeTrue) { |
@@ -3,7 +3,6 @@ |
||
3 | 3 | namespace whm\Smoke\Rules\Xml\Sitemap; |
4 | 4 | |
5 | 5 | use Psr\Http\Message\ResponseInterface; |
6 | -use whm\Smoke\Http\Response; |
|
7 | 6 | use whm\Smoke\Rules\StandardRule; |
8 | 7 | use whm\Smoke\Rules\ValidationFailedException; |
9 | 8 |
@@ -27,6 +27,9 @@ discard block |
||
27 | 27 | $this->strictMode = $strictMode; |
28 | 28 | } |
29 | 29 | |
30 | + /** |
|
31 | + * @param boolean $isIndex |
|
32 | + */ |
|
30 | 33 | private function getSchema($isIndex) |
31 | 34 | { |
32 | 35 | if ($isIndex) { |
@@ -40,6 +43,10 @@ discard block |
||
40 | 43 | } |
41 | 44 | } |
42 | 45 | |
46 | + /** |
|
47 | + * @param string $body |
|
48 | + * @param string $filename |
|
49 | + */ |
|
43 | 50 | private function validateBody($body, $filename, $isIndex = true) |
44 | 51 | { |
45 | 52 | $dom = new \DOMDocument(); |
@@ -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 | } |
@@ -41,12 +41,12 @@ discard block |
||
41 | 41 | public function init($filters = array(), $filterFile = '', $exclusive = array()) |
42 | 42 | { |
43 | 43 | if (count($exclusive) > 0 && (count($filters) > 0 || $filterFile !== '')) { |
44 | - throw new \RuntimeException("It's not possible to define filter lists and an exclusive list at the same time [Extension: " . get_class($this) . '].'); |
|
44 | + throw new \RuntimeException("It's not possible to define filter lists and an exclusive list at the same time [Extension: ".get_class($this).'].'); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | if ($filterFile !== '') { |
48 | 48 | if (!file_exists($filterFile)) { |
49 | - throw new \RuntimeException('Filter file not found: ' . $filterFile); |
|
49 | + throw new \RuntimeException('Filter file not found: '.$filterFile); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | $filterElements = EnvAwareYaml::parse(file_get_contents($filterFile)); |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | */ |
86 | 86 | public function isFiltered(Event $event, $ruleName, UriAwareResponse $response) |
87 | 87 | { |
88 | - $uri = (string)$this->retriever->getOriginUri($response->getUri()); |
|
88 | + $uri = (string) $this->retriever->getOriginUri($response->getUri()); |
|
89 | 89 | |
90 | 90 | if ($this->currentModus === self::MODUS_FILTER) { |
91 | 91 | $isFiltered = $this->isFilteredByFilter($ruleName, $uri); |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | private function isFilteredByFilter($ruleName, $uri) |
105 | 105 | { |
106 | 106 | foreach ($this->filters as $filter) { |
107 | - if ($ruleName === $filter['rule'] && 0 < preg_match('$' . $filter['uri'] . '$', $uri)) { |
|
107 | + if ($ruleName === $filter['rule'] && 0 < preg_match('$'.$filter['uri'].'$', $uri)) { |
|
108 | 108 | return true; |
109 | 109 | } |
110 | 110 | } |