PropertyPathIterator.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. /**
  21. * @param PropertyPathInterface $path The property path to traverse
  22. */
  23. public function __construct(PropertyPathInterface $path)
  24. {
  25. parent::__construct($path->getElements());
  26. $this->path = $path;
  27. }
  28. /**
  29. * {@inheritdoc}
  30. */
  31. public function isIndex()
  32. {
  33. return $this->path->isIndex($this->key());
  34. }
  35. /**
  36. * {@inheritdoc}
  37. */
  38. public function isProperty()
  39. {
  40. return $this->path->isProperty($this->key());
  41. }
  42. }