protected function getLinks(WebsiteConfig $config, array $checkerConfig = [])
 {
     $result = [];
     foreach ($checkerConfig['pages'] as $page) {
         $result[] = $config->getUrl() . $page;
     }
     return $result;
 }
 public function parse(WebsiteConfig $config, array $checkerConfig = [])
 {
     if (empty($checkerConfig['blacklist'])) {
         return 'Config error, no blacklist configured';
     }
     $blacklistString = implode(', ', $this->getBlacklist($config->getUrl(), $checkerConfig['blacklist']));
     return ['Check ' . $this->getLink($config->getUrl(), $checkerConfig), 'With following blacklist: ' . $blacklistString];
 }
Example #3
0
 public function check(WebsiteConfig $config, array $checkerConfig = [])
 {
     $failures = [];
     foreach ($checkerConfig as $page) {
         if (empty($page['page'])) {
             $failures[] = 'Config error, no page defined';
             continue;
         }
         $link = $config->getUrl() . $page['page'];
         $response = (new Client($link))->send();
         if (!$response->isOk()) {
             $failures = array_merge($failures, ['Can not request the sitemap at ' . $link . '.', 'The following error occurs: ' . $response->getStatusCode() . ' ' . $response->getReasonPhrase()]);
         }
         $failures = array_merge($failures, $this->checkPage($response->getBody(), $page));
     }
     return $failures;
 }
 private function getUrl(WebsiteConfig $config)
 {
     return $config->getUrl() . '/robots.txt';
 }