PropertyPathInterface.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. * A sequence of property names or array indices.
  13. *
  14. * @author Bernhard Schussek <bschussek@gmail.com>
  15. */
  16. interface PropertyPathInterface extends \Traversable
  17. {
  18. /**
  19. * Returns the string representation of the property path.
  20. *
  21. * @return string The path as string
  22. */
  23. public function __toString();
  24. /**
  25. * Returns the length of the property path, i.e. the number of elements.
  26. *
  27. * @return int The path length
  28. */
  29. public function getLength();
  30. /**
  31. * Returns the parent property path.
  32. *
  33. * The parent property path is the one that contains the same items as
  34. * this one except for the last one.
  35. *
  36. * If this property path only contains one item, null is returned.
  37. *
  38. * @return self|null The parent path or null
  39. */
  40. public function getParent();
  41. /**
  42. * Returns the elements of the property path as array.
  43. *
  44. * @return array An array of property/index names
  45. */
  46. public function getElements();
  47. /**
  48. * Returns the element at the given index in the property path.
  49. *
  50. * @param int $index The index key
  51. *
  52. * @return string A property or index name
  53. *
  54. * @throws Exception\OutOfBoundsException If the offset is invalid
  55. */
  56. public function getElement(int $index);
  57. /**
  58. * Returns whether the element at the given index is a property.
  59. *
  60. * @param int $index The index in the property path
  61. *
  62. * @return bool Whether the element at this index is a property
  63. *
  64. * @throws Exception\OutOfBoundsException If the offset is invalid
  65. */
  66. public function isProperty(int $index);
  67. /**
  68. * Returns whether the element at the given index is an array index.
  69. *
  70. * @param int $index The index in the property path
  71. *
  72. * @return bool Whether the element at this index is an array index
  73. *
  74. * @throws Exception\OutOfBoundsException If the offset is invalid
  75. */
  76. public function isIndex(int $index);
  77. }