Skip to content

Commit

Permalink
do not use array map for analyze anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimir-xz committed Jul 4, 2024
1 parent b3b5308 commit ec9edac
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/Urls/Analyze.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,11 @@ private function checkConnection(UrlCheck $url)
public static function checkParams(UrlCheck $url)
{
$document = new Document($url->getHtmlBody());
Arr::map(self::$analyzeParams, function ($value, $key) use ($document, $url) {
if (count($elements = $document->find($value)) == 0) {
return;
}
$result = optional($elements[0]->address)->street;
$command = 'set' . $key;
$url->$command($result);
});
$h1 = optional($document->first('h1'))->text();
$title = optional($document->first('title'))->text();
$description = optional($document->find('meta[name=description]')[0])->content;
$url->setH1($h1);
$url->setTitle($title);
$url->setDescription($description);
}
}

0 comments on commit ec9edac

Please sign in to comment.