CollectionInterface.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * @package Grav\Framework\Collection
  4. *
  5. * @copyright Copyright (C) 2015 - 2019 Trilby Media, LLC. All rights reserved.
  6. * @license MIT License; see LICENSE file for details.
  7. */
  8. namespace Grav\Framework\Collection;
  9. use Doctrine\Common\Collections\Collection;
  10. /**
  11. * Collection Interface.
  12. *
  13. * @package Grav\Framework\Collection
  14. */
  15. interface CollectionInterface extends Collection, \JsonSerializable
  16. {
  17. /**
  18. * Reverse the order of the items.
  19. *
  20. * @return static
  21. */
  22. public function reverse();
  23. /**
  24. * Shuffle items.
  25. *
  26. * @return static
  27. */
  28. public function shuffle();
  29. /**
  30. * Split collection into chunks.
  31. *
  32. * @param int $size Size of each chunk.
  33. * @return array
  34. */
  35. public function chunk($size);
  36. /**
  37. * Select items from collection.
  38. *
  39. * Collection is returned in the order of $keys given to the function.
  40. *
  41. * @param array $keys
  42. * @return static
  43. */
  44. public function select(array $keys);
  45. /**
  46. * Un-select items from collection.
  47. *
  48. * @param array $keys
  49. * @return static
  50. */
  51. public function unselect(array $keys);
  52. }