protected function isMatchToAutoFlushFilter() { if ($this->autoFlushContentTypeFilter) { $contentTypeHeaderPrefix = 'Content-type:'; foreach (headers_list() as $header) { if (stripos($header, $contentTypeHeaderPrefix) === 0) { return $this->autoFlushContentTypeFilter->isMatch(substr($header, strlen($contentTypeHeaderPrefix))); } } return false; } return true; }
protected function isValidInternalLink($linkPath, $source) { if (!SpeedOut_Utils::isExternalLink($linkPath) && !is_file($linkPath)) { if ($this->internalLinksValidationFilter && $this->internalLinksValidationFilter->isMatch($linkPath)) { throw new SpeedOut_DataHandler_Combiner_Exception_PathNotFound($linkPath, $source); } return false; } return true; }
protected function getLinksNodes($html) { $html = $this->removeHtmlComments($html); $linksData = array(); foreach ($this->getLinksNodesRegexps() as $regexp) { if (SpeedOut_Utils::safePregMatchAll($regexp, $html, $m)) { foreach ($m[1] as $i => $link) { if (!SpeedOut_Utils::isExternalLink($link) && $this->linksFilter->isMatch($link)) { $linksData[$link] = $m[0][$i]; } } } } return $linksData; }
/** * @dataProvider filterRegexpsProvider */ public function testFilter(array $requiredRegexps, array $excludedRegexps, $expectedIsMatch) { $filter = new SpeedOut_Filter($requiredRegexps, $excludedRegexps, $expectedIsMatch); $this->assertEquals($expectedIsMatch, $filter->isMatch(self::FILTER_DATA)); }