/** * @param $node \Symfony\Component\DomCrawler\Crawler * @param string $attr * @param $trim * @return string */ public function getValue($node, $attr, $trim) { $temp = ''; try { if (Utils::isBlank($attr)) { $temp = $node->text(); } else { $temp = $node->attr($attr); } } catch (\Exception $e) { } if ($trim == 'timestamp') { $temp = preg_replace('/.*ldst_strftime\\(/', '', $temp); $temp = preg_replace('/,.*/', "", $temp); $temp = trim($temp); } if ($trim == 'hash') { preg_match('/([0-9a-zA-Z]+)$/', $temp, $m); $temp = trim($m[0]); } return Utils::trimQsa($temp); }
/** * @cover Lodestone\Utils::isBlank */ public function testUtilsIsBlank_greedy指定なしで全角スペースと非空白の組み合わせの場合_falseが返る() { $input = ' A '; $this->assertFalse(Utils::isBlank($input, false), $input); }
public function testApiAbstract_scrapingのmappingが空の時_HTMLを取得する() { $mock = new ApiMock(); $crawler = $mock->getCrawler('GET', $this->url . $this->id); $this->assertTrue(!Utils::isBlank($mock->scraping($crawler, []))); }