Link.php 847 B

1234567891011121314151617181920212223242526272829303132333435
  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. * Link represents an HTML link (an HTML a, area or link tag).
  13. *
  14. * @author Fabien Potencier <fabien@symfony.com>
  15. */
  16. class Link extends AbstractUriElement
  17. {
  18. protected function getRawUri()
  19. {
  20. return $this->node->getAttribute('href');
  21. }
  22. protected function setNode(\DOMElement $node)
  23. {
  24. if ('a' !== $node->nodeName && 'area' !== $node->nodeName && 'link' !== $node->nodeName) {
  25. throw new \LogicException(sprintf('Unable to navigate from a "%s" tag.', $node->nodeName));
  26. }
  27. $this->node = $node;
  28. }
  29. }