コード例 #1
0
ファイル: UrlResolver.php プロジェクト: innmind/crawler
 /**
  * @param  RequestInterface $request
  * @param  MapInterface<string, AttributeInterface> $attributes
  * @param  UrlInterface $target
  */
 public function resolve(RequestInterface $request, MapInterface $attributes, UrlInterface $target) : UrlInterface
 {
     $base = $request->url();
     if ($attributes->contains(BaseParser::key())) {
         $base = $attributes->get(BaseParser::key())->content();
     }
     return Url::fromString($this->resolver->resolve((string) $base, (string) $target));
 }
コード例 #2
0
ファイル: AlternatesParser.php プロジェクト: innmind/crawler
 private function merge(MapInterface $http, MapInterface $html) : MapInterface
 {
     if (!$http->contains(HttpParser::key())) {
         return $html;
     }
     if (!$html->contains(HtmlParser::key())) {
         return $http;
     }
     return $http->put(self::key(), $http->get(HttpParser::key())->merge($html->get(HtmlParser::key())));
 }
コード例 #3
0
ファイル: ImageTrait.php プロジェクト: innmind/crawler
 private function isImage(MapInterface $attributes) : bool
 {
     return $attributes->contains(ContentTypeParser::key()) && (new Image())->isSatisfiedBy($attributes->get(ContentTypeParser::key())->content());
 }