PropertyPathIterator.php 999 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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\PropertyAccess;
  11. /**
  12. * Traverses a property path and provides additional methods to find out
  13. * information about the current element.
  14. *
  15. * @author Bernhard Schussek <bschussek@gmail.com>
  16. */
  17. class PropertyPathIterator extends \ArrayIterator implements PropertyPathIteratorInterface
  18. {
  19. protected $path;
  20. public function __construct(PropertyPathInterface $path)
  21. {
  22. parent::__construct($path->getElements());
  23. $this->path = $path;
  24. }
  25. /**
  26. * {@inheritdoc}
  27. */
  28. public function isIndex()
  29. {
  30. return $this->path->isIndex($this->key());
  31. }
  32. /**
  33. * {@inheritdoc}
  34. */
  35. public function isProperty()
  36. {
  37. return $this->path->isProperty($this->key());
  38. }
  39. }