NestedObjectInterface.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * @package Grav\Framework\Object
  4. *
  5. * @copyright Copyright (c) 2015 - 2023 Trilby Media, LLC. All rights reserved.
  6. * @license MIT License; see LICENSE file for details.
  7. */
  8. namespace Grav\Framework\Object\Interfaces;
  9. use RuntimeException;
  10. /**
  11. * Common Interface for both Objects and Collections
  12. * @package Grav\Framework\Object
  13. */
  14. interface NestedObjectInterface extends ObjectInterface
  15. {
  16. /**
  17. * @param string $property Object property name.
  18. * @param string|null $separator Separator, defaults to '.'
  19. * @return bool|bool[] True if property has been defined (can be null).
  20. */
  21. public function hasNestedProperty($property, $separator = null);
  22. /**
  23. * @param string $property Object property to be fetched.
  24. * @param mixed|null $default Default value if property has not been set.
  25. * @param string|null $separator Separator, defaults to '.'
  26. * @return mixed|mixed[] Property value.
  27. */
  28. public function getNestedProperty($property, $default = null, $separator = null);
  29. /**
  30. * @param string $property Object property to be updated.
  31. * @param mixed $value New value.
  32. * @param string|null $separator Separator, defaults to '.'
  33. * @return $this
  34. * @throws RuntimeException
  35. */
  36. public function setNestedProperty($property, $value, $separator = null);
  37. /**
  38. * @param string $property Object property to be defined.
  39. * @param mixed $default Default value.
  40. * @param string|null $separator Separator, defaults to '.'
  41. * @return $this
  42. * @throws RuntimeException
  43. */
  44. public function defNestedProperty($property, $default, $separator = null);
  45. /**
  46. * @param string $property Object property to be unset.
  47. * @param string|null $separator Separator, defaults to '.'
  48. * @return $this
  49. * @throws RuntimeException
  50. */
  51. public function unsetNestedProperty($property, $separator = null);
  52. }