PropertyPathIterator.php 980 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. * @extends \ArrayIterator<int, string>
  18. */
  19. class PropertyPathIterator extends \ArrayIterator implements PropertyPathIteratorInterface
  20. {
  21. protected $path;
  22. public function __construct(PropertyPathInterface $path)
  23. {
  24. parent::__construct($path->getElements());
  25. $this->path = $path;
  26. }
  27. public function isIndex(): bool
  28. {
  29. return $this->path->isIndex($this->key());
  30. }
  31. public function isProperty(): bool
  32. {
  33. return $this->path->isProperty($this->key());
  34. }
  35. }