diff options
Diffstat (limited to 'symfony/dom-crawler/Image.php')
-rw-r--r-- | symfony/dom-crawler/Image.php | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/symfony/dom-crawler/Image.php b/symfony/dom-crawler/Image.php new file mode 100644 index 00000000..b1ac5ca2 --- /dev/null +++ b/symfony/dom-crawler/Image.php @@ -0,0 +1,37 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\DomCrawler; + +/** + * Image represents an HTML image (an HTML img tag). + */ +class Image extends AbstractUriElement +{ + public function __construct(\DOMElement $node, string $currentUri = null) + { + parent::__construct($node, $currentUri, 'GET'); + } + + protected function getRawUri() + { + return $this->node->getAttribute('src'); + } + + protected function setNode(\DOMElement $node) + { + if ('img' !== $node->nodeName) { + throw new \LogicException(sprintf('Unable to visualize a "%s" tag.', $node->nodeName)); + } + + $this->node = $node; + } +} |