@@ -42,12 +42,12 @@ discard block |
||
| 42 | 42 | public function init($filters = array(), $filterFile = '', $exclusive = array()) |
| 43 | 43 | { |
| 44 | 44 | if (count($exclusive) > 0 && (count($filters) > 0 || $filterFile !== '')) { |
| 45 | - throw new \RuntimeException("It's not possible to define filter lists and an exclusive list at the same time [Extension: " . get_class($this) . '].'); |
|
| 45 | + throw new \RuntimeException("It's not possible to define filter lists and an exclusive list at the same time [Extension: ".get_class($this).'].'); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | if ($filterFile !== '') { |
| 49 | 49 | if (!file_exists($filterFile)) { |
| 50 | - throw new \RuntimeException('Filter file not found: ' . $filterFile); |
|
| 50 | + throw new \RuntimeException('Filter file not found: '.$filterFile); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | $filterElements = EnvAwareYaml::parse(file_get_contents($filterFile)); |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | if (is_array($urls)) { |
| 73 | 73 | foreach ($urls as $url) { |
| 74 | 74 | $uri = new Uri($url); |
| 75 | - $this->exclusives[$rule][] = (string)$uri; |
|
| 75 | + $this->exclusives[$rule][] = (string) $uri; |
|
| 76 | 76 | } |
| 77 | 77 | } |
| 78 | 78 | } |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | */ |
| 94 | 94 | public function isFiltered(Event $event, $ruleName, UriAwareResponse $response) |
| 95 | 95 | { |
| 96 | - $uri = (string)$this->retriever->getOriginUri($response->getUri()); |
|
| 96 | + $uri = (string) $this->retriever->getOriginUri($response->getUri()); |
|
| 97 | 97 | |
| 98 | 98 | if ($this->currentModus === self::MODUS_FILTER) { |
| 99 | 99 | $isFiltered = $this->isFilteredByFilter($ruleName, $uri); |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | private function isFilteredByFilter($ruleName, $uri) |
| 113 | 113 | { |
| 114 | 114 | foreach ($this->filters as $filter) { |
| 115 | - if ($ruleName === $filter['rule'] && 0 < preg_match('$' . $filter['uri'] . '$', $uri)) { |
|
| 115 | + if ($ruleName === $filter['rule'] && 0 < preg_match('$'.$filter['uri'].'$', $uri)) { |
|
| 116 | 116 | return true; |
| 117 | 117 | } |
| 118 | 118 | } |
@@ -16,7 +16,6 @@ |
||
| 16 | 16 | protected $contentTypes = array('text/html', 'application/json', 'application/xml'); |
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | - * @param int $string The string that the document must contain |
|
| 20 | 19 | */ |
| 21 | 20 | public function init(array $regExs) |
| 22 | 21 | { |
@@ -42,12 +42,12 @@ discard block |
||
| 42 | 42 | if ($regEx['isRegEx']) { |
| 43 | 43 | $pattern = str_replace('', '\\~', $regEx['pattern']); |
| 44 | 44 | |
| 45 | - if (preg_match('~' . $pattern . '~', (string)$response->getBody()) === 0) { |
|
| 46 | - $errors[] = 'Regular expression: ' . $regEx['pattern']; |
|
| 45 | + if (preg_match('~'.$pattern.'~', (string) $response->getBody()) === 0) { |
|
| 46 | + $errors[] = 'Regular expression: '.$regEx['pattern']; |
|
| 47 | 47 | } |
| 48 | 48 | } else { |
| 49 | - if (preg_match('^' . preg_quote($regEx['pattern']) . '^', (string)$response->getBody()) === 0) { |
|
| 50 | - $errors[] = 'Text: ' . $regEx['pattern']; |
|
| 49 | + if (preg_match('^'.preg_quote($regEx['pattern']).'^', (string) $response->getBody()) === 0) { |
|
| 50 | + $errors[] = 'Text: '.$regEx['pattern']; |
|
| 51 | 51 | } |
| 52 | 52 | } |
| 53 | 53 | } |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | $errorString = 'The following text elements were not found: <ul>'; |
| 57 | 57 | |
| 58 | 58 | foreach ($errors as $error) { |
| 59 | - $errorString .= '<li>' . $error . '</li>'; |
|
| 59 | + $errorString .= '<li>'.$error.'</li>'; |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | $errorString .= '</ul>'; |
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | foreach ($results as $result) { |
| 36 | 36 | /** @var UriAwareResponse $response */ |
| 37 | 37 | if ($result->getStatus() == CheckResult::STATUS_FAILURE) { |
| 38 | - $this->memory[] = (string)$response->getUri(); |
|
| 38 | + $this->memory[] = (string) $response->getUri(); |
|
| 39 | 39 | } |
| 40 | 40 | } |
| 41 | 41 | } |
@@ -31,23 +31,23 @@ |
||
| 31 | 31 | $uri = new Uri($url['url']); |
| 32 | 32 | |
| 33 | 33 | $urlResponses = $client->sendRequests([new Request('GET', $uri)]); |
| 34 | - $effectiveUrl = (string)$urlResponses[0]->getEffectiveUri(); |
|
| 34 | + $effectiveUrl = (string) $urlResponses[0]->getEffectiveUri(); |
|
| 35 | 35 | |
| 36 | - if ($effectiveUrl != (string)$response->getUri()) { |
|
| 37 | - $errors[] = 'The url "' . $url['url'] . '" gets redirected to "' . $effectiveUrl . '".'; |
|
| 36 | + if ($effectiveUrl != (string) $response->getUri()) { |
|
| 37 | + $errors[] = 'The url "'.$url['url'].'" gets redirected to "'.$effectiveUrl.'".'; |
|
| 38 | 38 | } |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | if (count($errors) > 0) { |
| 42 | - $message = 'Not all given urls do redirect to "' . (string)$response->getUri() . '"".<ul>'; |
|
| 42 | + $message = 'Not all given urls do redirect to "'.(string) $response->getUri().'"".<ul>'; |
|
| 43 | 43 | foreach ($errors as $error) { |
| 44 | - $message .= '<li>' . $error . '</li>'; |
|
| 44 | + $message .= '<li>'.$error.'</li>'; |
|
| 45 | 45 | } |
| 46 | 46 | $message .= "</ul>"; |
| 47 | 47 | |
| 48 | 48 | return new CheckResult(CheckResult::STATUS_FAILURE, $message); |
| 49 | 49 | } else { |
| 50 | - return new CheckResult(CheckResult::STATUS_SUCCESS, 'All given urls redirect to ' . (string)$response->getUri()); |
|
| 50 | + return new CheckResult(CheckResult::STATUS_SUCCESS, 'All given urls redirect to '.(string) $response->getUri()); |
|
| 51 | 51 | } |
| 52 | 52 | } |
| 53 | 53 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | if ($response instanceof ContentTypeAwareResponse) { |
| 18 | 18 | |
| 19 | 19 | // @todo this could be part of the StandardRule class |
| 20 | - $body = (string)$response->getBody(); |
|
| 20 | + $body = (string) $response->getBody(); |
|
| 21 | 21 | $body = preg_replace('/[\x00-\x09\x0B\x0C\x0E-\x1F\x7F,\xFF,\x8B]/', '', $body); |
| 22 | 22 | |
| 23 | 23 | if (($response->getStatusCode() < 300 || $response->getStatusCode() >= 400) |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | && strlen($body) > 0 |
| 26 | 26 | ) { |
| 27 | 27 | if (stripos($body, '</html>') === false) { |
| 28 | - throw new ValidationFailedException('Closing html tag is missing (document length: ' . strlen($body) . ').'); |
|
| 28 | + throw new ValidationFailedException('Closing html tag is missing (document length: '.strlen($body).').'); |
|
| 29 | 29 | } |
| 30 | 30 | } |
| 31 | 31 | } |
@@ -18,19 +18,19 @@ |
||
| 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 | |
| 27 | - $idnUrl = $url->getScheme() . '://' . idn_to_ascii($url->getHost()) . $url->getPath(); |
|
| 27 | + $idnUrl = $url->getScheme().'://'.idn_to_ascii($url->getHost()).$url->getPath(); |
|
| 28 | 28 | |
| 29 | 29 | if (!filter_var($idnUrl, FILTER_VALIDATE_URL)) { |
| 30 | - $invalidUrls[] = (string)$url; |
|
| 30 | + $invalidUrls[] = (string) $url; |
|
| 31 | 31 | } |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - $this->assert(count($invalidUrls) === 0, 'Invalid urls found (' . implode(', ', $invalidUrls) . ').'); |
|
| 34 | + $this->assert(count($invalidUrls) === 0, 'Invalid urls found ('.implode(', ', $invalidUrls).').'); |
|
| 35 | 35 | } |
| 36 | 36 | } |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | return; |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - $htmlDocument = new Document((string)$response->getBody()); |
|
| 47 | + $htmlDocument = new Document((string) $response->getBody()); |
|
| 48 | 48 | |
| 49 | 49 | $resources = $htmlDocument->getDependencies($uri, false); |
| 50 | 50 | |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | if ($resource->getScheme() && 'https' !== $resource->getScheme()) { |
| 55 | 55 | $excluded = false; |
| 56 | 56 | foreach ($this->excludedFiles as $excludedFile) { |
| 57 | - if (preg_match('~' . $excludedFile . '~', (string)$resource)) { |
|
| 57 | + if (preg_match('~'.$excludedFile.'~', (string) $resource)) { |
|
| 58 | 58 | $excluded = true; |
| 59 | 59 | break; |
| 60 | 60 | } |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | if (count($unsecures) > 0) { |
| 69 | 69 | $message = 'At least one dependency was found on a secure url, that was transfered insecure.<ul>'; |
| 70 | 70 | foreach ($unsecures as $unsecure) { |
| 71 | - $message .= '<li>' . (string)$unsecure . '</li>'; |
|
| 71 | + $message .= '<li>'.(string) $unsecure.'</li>'; |
|
| 72 | 72 | } |
| 73 | 73 | $message .= '</ul>'; |
| 74 | 74 | return new CheckResult(CheckResult::STATUS_FAILURE, $message, count($unsecures)); |
@@ -21,12 +21,12 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | private function getSchema() |
| 23 | 23 | { |
| 24 | - return __DIR__ . '/' . self::SCHEMA; |
|
| 24 | + return __DIR__.'/'.self::SCHEMA; |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | public function doValidation(ResponseInterface $response) |
| 28 | 28 | { |
| 29 | - $body = (string)$response->getBody(); |
|
| 29 | + $body = (string) $response->getBody(); |
|
| 30 | 30 | |
| 31 | 31 | if (preg_match('/<rss/', $body)) { |
| 32 | 32 | libxml_clear_errors(); |
@@ -35,8 +35,8 @@ discard block |
||
| 35 | 35 | $lastError = libxml_get_last_error(); |
| 36 | 36 | if ($lastError) { |
| 37 | 37 | throw new ValidationFailedException( |
| 38 | - 'The given xml file is not well formed (last error: ' . |
|
| 39 | - str_replace("\n", '', $lastError->message) . ').'); |
|
| 38 | + 'The given xml file is not well formed (last error: '. |
|
| 39 | + str_replace("\n", '', $lastError->message).').'); |
|
| 40 | 40 | } |
| 41 | 41 | $valid = @$dom->schemaValidate($this->getSchema()); |
| 42 | 42 | if (!$valid) { |
@@ -44,11 +44,11 @@ discard block |
||
| 44 | 44 | $lastErrorMessage = str_replace("\n", '', $lastError->message); |
| 45 | 45 | |
| 46 | 46 | if ($response instanceof UriAwareResponse) { |
| 47 | - $toolUrl = sprintf(self::PUBLIC_SERVICE, urlencode((string)$response->getUri())); |
|
| 47 | + $toolUrl = sprintf(self::PUBLIC_SERVICE, urlencode((string) $response->getUri())); |
|
| 48 | 48 | } else { |
| 49 | 49 | $toolUrl = ''; |
| 50 | 50 | } |
| 51 | - return new CheckResult(CheckResult::STATUS_FAILURE, 'The given xml file is not a valid rss file (last error: ' . $lastErrorMessage . ').', null, $toolUrl); |
|
| 51 | + return new CheckResult(CheckResult::STATUS_FAILURE, 'The given xml file is not a valid rss file (last error: '.$lastErrorMessage.').', null, $toolUrl); |
|
| 52 | 52 | } |
| 53 | 53 | } |
| 54 | 54 | return new CheckResult(CheckResult::STATUS_SUCCESS, 'The given rss file is valid.'); |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | $configArray = $this->getConfigArray($configFile, true); |
| 51 | 51 | |
| 52 | 52 | if (is_string($configArray)) { |
| 53 | - throw new \RuntimeException('Unable to load config file. Please check ' . $configFile); |
|
| 53 | + throw new \RuntimeException('Unable to load config file. Please check '.$configFile); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | $this->config = new Configuration(new Uri('http://www.example.com'), $dispatcher, $configArray); |