ObjectCollectionInterface.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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 Doctrine\Common\Collections\Selectable;
  10. use Grav\Framework\Collection\CollectionInterface;
  11. use Serializable;
  12. /**
  13. * ObjectCollection Interface
  14. * @package Grav\Framework\Collection
  15. * @template TKey of array-key
  16. * @template T
  17. * @extends CollectionInterface<TKey,T>
  18. * @extends Selectable<TKey,T>
  19. */
  20. interface ObjectCollectionInterface extends CollectionInterface, Selectable, Serializable
  21. {
  22. /**
  23. * @return string
  24. */
  25. public function getType();
  26. /**
  27. * @return string
  28. */
  29. public function getKey();
  30. /**
  31. * @param string $key
  32. * @return $this
  33. */
  34. public function setKey($key);
  35. /**
  36. * @param string $property Object property name.
  37. * @return bool[] List of [key => bool] pairs.
  38. */
  39. public function hasProperty($property);
  40. /**
  41. * @param string $property Object property to be fetched.
  42. * @param mixed|null $default Default value if property has not been set.
  43. * @return mixed[] List of [key => value] pairs.
  44. */
  45. public function getProperty($property, $default = null);
  46. /**
  47. * @param string $property Object property to be updated.
  48. * @param mixed $value New value.
  49. * @return $this
  50. */
  51. public function setProperty($property, $value);
  52. /**
  53. * @param string $property Object property to be defined.
  54. * @param mixed $default Default value.
  55. * @return $this
  56. */
  57. public function defProperty($property, $default);
  58. /**
  59. * @param string $property Object property to be unset.
  60. * @return $this
  61. */
  62. public function unsetProperty($property);
  63. /**
  64. * Create a copy from this collection by cloning all objects in the collection.
  65. *
  66. * @return static
  67. * @phpstan-return static<TKey,T>
  68. */
  69. public function copy();
  70. /**
  71. * @return array
  72. */
  73. public function getObjectKeys();
  74. /**
  75. * @param string $name Method name.
  76. * @param array $arguments List of arguments passed to the function.
  77. * @return array Return values.
  78. */
  79. public function call($name, array $arguments = []);
  80. /**
  81. * Group items in the collection by a field and return them as associated array.
  82. *
  83. * @param string $property
  84. * @return array
  85. */
  86. public function group($property);
  87. /**
  88. * Group items in the collection by a field and return them as associated array of collections.
  89. *
  90. * @param string $property
  91. * @return static[]
  92. * @phpstan-return array<static<TKey,T>>
  93. */
  94. public function collectionGroup($property);
  95. /**
  96. * @param array $ordering
  97. * @return ObjectCollectionInterface
  98. * @phpstan-return static<TKey,T>
  99. */
  100. public function orderBy(array $ordering);
  101. /**
  102. * @param int $start
  103. * @param int|null $limit
  104. * @return ObjectCollectionInterface
  105. * @phpstan-return static<TKey,T>
  106. */
  107. public function limit($start, $limit = null);
  108. }