@@ -39,12 +39,12 @@ |
||
39 | 39 | $error = true; |
40 | 40 | $lastError = libxml_get_last_error(); |
41 | 41 | |
42 | - $messageParts[] = $xsdFile['xsdfilename'] . ' - ' . $xsdFile['xsdfileurl'] . '(last error: ' . str_replace("\n", '', $lastError->message) . ').'; |
|
42 | + $messageParts[] = $xsdFile['xsdfilename'].' - '.$xsdFile['xsdfileurl'].'(last error: '.str_replace("\n", '', $lastError->message).').'; |
|
43 | 43 | } |
44 | 44 | } |
45 | 45 | |
46 | 46 | if ($error === true) { |
47 | - $message = 'XML file (' . $filename . ') does not validate against the following XSD files: ' . implode(', ', $messageParts); |
|
47 | + $message = 'XML file ('.$filename.') does not validate against the following XSD files: '.implode(', ', $messageParts); |
|
48 | 48 | throw new ValidationFailedException($message); |
49 | 49 | } |
50 | 50 | } |
@@ -15,7 +15,7 @@ |
||
15 | 15 | { |
16 | 16 | if (($response->getStatus() < 300 || $response->getStatus() >= 400) && $response->getContentType() === 'text/html') { |
17 | 17 | if (stripos($response->getBody(), '</html>') === false) { |
18 | - throw new ValidationFailedException('Closing html tag is missing (document lengh: ' . strlen($response->getBody()) . ').'); |
|
18 | + throw new ValidationFailedException('Closing html tag is missing (document lengh: '.strlen($response->getBody()).').'); |
|
19 | 19 | } |
20 | 20 | } |
21 | 21 | } |
@@ -49,6 +49,9 @@ |
||
49 | 49 | } |
50 | 50 | } |
51 | 51 | |
52 | + /** |
|
53 | + * @param string $content |
|
54 | + */ |
|
52 | 55 | private function normalizeContent($content) |
53 | 56 | { |
54 | 57 | $normalizedContent = strtolower($content); |
@@ -20,12 +20,12 @@ discard block |
||
20 | 20 | |
21 | 21 | public function validate(Response $response) |
22 | 22 | { |
23 | - $url = $response->getUri()->getScheme() . '://' . $response->getUri()->getHost(); |
|
23 | + $url = $response->getUri()->getScheme().'://'.$response->getUri()->getHost(); |
|
24 | 24 | |
25 | 25 | if (substr_count($url, '/') === 2) { |
26 | - $filename = $robotsUrl = $url . '/robots.txt'; |
|
26 | + $filename = $robotsUrl = $url.'/robots.txt'; |
|
27 | 27 | } elseif (substr_count($url, '/') === 3) { |
28 | - $filename = $robotsUrl = $url . 'robots.txt'; |
|
28 | + $filename = $robotsUrl = $url.'robots.txt'; |
|
29 | 29 | } else { |
30 | 30 | return; |
31 | 31 | } |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | |
41 | 41 | $normalizedContent = $this->normalizeContent($content); |
42 | 42 | |
43 | - if (strpos($normalizedContent, 'user-agent:* disallow:/' . PHP_EOL) !== false) { |
|
43 | + if (strpos($normalizedContent, 'user-agent:* disallow:/'.PHP_EOL) !== false) { |
|
44 | 44 | throw new ValidationFailedException('The robots.txt contains disallow all (Disallow: /)'); |
45 | 45 | } |
46 | 46 |
@@ -72,6 +72,9 @@ |
||
72 | 72 | $this->output->writeln(''); |
73 | 73 | } |
74 | 74 | |
75 | + /** |
|
76 | + * @param integer $ruleKey |
|
77 | + */ |
|
75 | 78 | private function getFailedUrls($ruleKey) |
76 | 79 | { |
77 | 80 | $failedUrls = array(); |
@@ -81,11 +81,11 @@ discard block |
||
81 | 81 | /** @var CheckResult $result */ |
82 | 82 | if ($result->getStatus() === CheckResult::STATUS_FAILURE) { |
83 | 83 | if ($ruleKey === $key) { |
84 | - $failedUrls[] = (string) $result->getResponse()->getUri() . ' - ' . $result->getMessage(); |
|
84 | + $failedUrls[] = (string) $result->getResponse()->getUri().' - '.$result->getMessage(); |
|
85 | 85 | ++$count; |
86 | 86 | } |
87 | 87 | if ($count > $this->maxResults) { |
88 | - $failedUrls[] = '... only the first ' . $this->maxResults . ' elements are shown.'; |
|
88 | + $failedUrls[] = '... only the first '.$this->maxResults.' elements are shown.'; |
|
89 | 89 | break; |
90 | 90 | } |
91 | 91 | } |
@@ -104,15 +104,15 @@ discard block |
||
104 | 104 | $failedUrls = $this->getFailedUrls($ruleKey); |
105 | 105 | |
106 | 106 | if (count($failedUrls) > 0) { |
107 | - $this->output->writeln(' <error> ' . get_class($rule) . ' </error>'); |
|
107 | + $this->output->writeln(' <error> '.get_class($rule).' </error>'); |
|
108 | 108 | } else { |
109 | - $this->output->writeln(' <info> ' . get_class($rule) . ' </info>'); |
|
109 | + $this->output->writeln(' <info> '.get_class($rule).' </info>'); |
|
110 | 110 | } |
111 | 111 | |
112 | - $this->output->writeln(' ' . str_replace("\n", "\n ", $info['documentation']) . "\n"); |
|
112 | + $this->output->writeln(' '.str_replace("\n", "\n ", $info['documentation'])."\n"); |
|
113 | 113 | |
114 | 114 | foreach ($failedUrls as $failedUrl) { |
115 | - $this->output->writeln(' - ' . $failedUrl); |
|
115 | + $this->output->writeln(' - '.$failedUrl); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | $this->output->writeln(''); |
@@ -30,13 +30,13 @@ |
||
30 | 30 | |
31 | 31 | protected function renderFailure(CheckResult $result) |
32 | 32 | { |
33 | - $this->output->writeln(' <error> ' . (string) $result->getResponse()->getUri() . ' </error> coming from ' . (string) $this->retriever->getComingFrom($result->getResponse()->getUri())); |
|
34 | - $this->output->writeln(' - ' . $result->getMessage() . ' [rule: ' . $result->getRuleName() . ']'); |
|
33 | + $this->output->writeln(' <error> '.(string) $result->getResponse()->getUri().' </error> coming from '.(string) $this->retriever->getComingFrom($result->getResponse()->getUri())); |
|
34 | + $this->output->writeln(' - '.$result->getMessage().' [rule: '.$result->getRuleName().']'); |
|
35 | 35 | $this->output->writeln(''); |
36 | 36 | } |
37 | 37 | |
38 | 38 | protected function renderSuccess(CheckResult $result) |
39 | 39 | { |
40 | - $this->output->writeln(' <info> ' . (string) $result->getResponse()->getUri() . ' </info> all tests passed'); |
|
40 | + $this->output->writeln(' <info> '.(string) $result->getResponse()->getUri().' </info> all tests passed'); |
|
41 | 41 | } |
42 | 42 | } |
@@ -43,6 +43,11 @@ |
||
43 | 43 | return json_decode($systems->getBody(), true); |
44 | 44 | } |
45 | 45 | |
46 | + /** |
|
47 | + * @param string $url |
|
48 | + * |
|
49 | + * @return string |
|
50 | + */ |
|
46 | 51 | private function prepareUrl($url) |
47 | 52 | { |
48 | 53 | $preparedUrl = str_replace('#project#', $this->project, $url); |
@@ -73,17 +73,17 @@ |
||
73 | 73 | |
74 | 74 | if ($jsonValue === false || (is_array($jsonValue) && empty($jsonValue))) { |
75 | 75 | $error = true; |
76 | - $noCorrectJsonPaths[] = $path['pattern'] . ' (JSON Path not found)'; |
|
76 | + $noCorrectJsonPaths[] = $path['pattern'].' (JSON Path not found)'; |
|
77 | 77 | } |
78 | 78 | if ($this->checkRelation($path['relation'], $path['value'], $count) === false) { |
79 | 79 | $error = true; |
80 | - $noCorrectJsonPaths[] = $path['pattern'] . ' (number of JSONPaths is not correct corresponding to the given relation/value)'; |
|
80 | + $noCorrectJsonPaths[] = $path['pattern'].' (number of JSONPaths is not correct corresponding to the given relation/value)'; |
|
81 | 81 | } |
82 | 82 | } |
83 | 83 | |
84 | 84 | if ($error === true) { |
85 | 85 | $allNoCorrectJsonPaths = implode('", "', $noCorrectJsonPaths); |
86 | - throw new ValidationFailedException('Disonances with JSON Paths "' . $allNoCorrectJsonPaths . '!'); |
|
86 | + throw new ValidationFailedException('Disonances with JSON Paths "'.$allNoCorrectJsonPaths.'!'); |
|
87 | 87 | } |
88 | 88 | } |
89 | 89 | } |
@@ -31,15 +31,15 @@ |
||
31 | 31 | |
32 | 32 | if ($xpath['relation'] === 'equals') { |
33 | 33 | $result = $count === (int) $xpath['value']; |
34 | - $message = 'The xpath "' . $xpath['pattern'] . '" was found ' . $count . ' times. Expected were exact ' . $xpath['value'] . ' occurencies.'; |
|
34 | + $message = 'The xpath "'.$xpath['pattern'].'" was found '.$count.' times. Expected were exact '.$xpath['value'].' occurencies.'; |
|
35 | 35 | } elseif ($xpath['relation'] === 'less than') { |
36 | 36 | $result = $count < (int) $xpath['value']; |
37 | - $message = 'The xpath "' . $xpath['pattern'] . '" was found ' . $count . ' times. Expected were less than ' . $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 | 39 | $result = $count > (int) $xpath['value']; |
40 | - $message = 'The xpath "' . $xpath['pattern'] . '" was found ' . $count . ' times. Expected were more than ' . $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); |
@@ -23,10 +23,10 @@ |
||
23 | 23 | { |
24 | 24 | if (array_key_exists('issuer', $certInfo) and array_key_exists('CN', $certInfo['issuer'])) { |
25 | 25 | if ($certInfo['issuer']['CN'] !== $this->authorityName) { |
26 | - throw new ValidationFailedException('Expected authority was "' . $this->authorityName . '", "' . $certInfo['issuer']['CN'] . '" found.'); |
|
26 | + throw new ValidationFailedException('Expected authority was "'.$this->authorityName.'", "'.$certInfo['issuer']['CN'].'" found.'); |
|
27 | 27 | } |
28 | 28 | } else { |
29 | - throw new ValidationFailedException('Expected authority was "' . $this->authorityName . '". No authority found.'); |
|
29 | + throw new ValidationFailedException('Expected authority was "'.$this->authorityName.'". No authority found.'); |
|
30 | 30 | } |
31 | 31 | } |
32 | 32 | } |