/** * @return Person */ public static function parseFromDomCrawler(Crawler $crawler) { $content = $crawler->filter('.div-cell div div')->text(); $content = StringHelper::removeEmptyLines($content); $contentItems = explode(PHP_EOL, $content); $name = trim(explode(',', $contentItems[0])[0]); $birthday = DateTimeParser::parseFromCzechDateString($contentItems[1]); $address = trim($contentItems[2]); return new Person($name, $birthday, $address); }
/** * @param Crawler $crawler * @return Person */ public static function parseFromDomCrawler(Crawler $crawler) { $content = $crawler->text(); $content = StringHelper::removeEmptyLines($content); $contentItems = explode("\n", $content); $contentItems = array_map('trim', $contentItems); $name = trim(explode(',', $contentItems[1])[0]); $birthday = DateTimeParser::parseFromCzechDateString($contentItems[2]); return new Person($name, $birthday, $contentItems[3]); }