Image.php 870 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\DomCrawler;
  11. /**
  12. * Image represents an HTML image (an HTML img tag).
  13. */
  14. class Image extends AbstractUriElement
  15. {
  16. public function __construct(\DOMElement $node, string $currentUri = null)
  17. {
  18. parent::__construct($node, $currentUri, 'GET');
  19. }
  20. protected function getRawUri()
  21. {
  22. return $this->node->getAttribute('src');
  23. }
  24. protected function setNode(\DOMElement $node)
  25. {
  26. if ('img' !== $node->nodeName) {
  27. throw new \LogicException(sprintf('Unable to visualize a "%s" tag.', $node->nodeName));
  28. }
  29. $this->node = $node;
  30. }
  31. }