ArrayIterator.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. namespace Gogs\Lib {
  3. /**
  4. * Interface to store one or more elements in array
  5. * providing an iterator interface.
  6. * @version 0.1.1
  7. */
  8. interface ArrayIterator {
  9. // Default sorting method; ksort (array index)
  10. const SORT_INDEX = 1 << 1;
  11. /**
  12. * Get current element in collection.
  13. * @return
  14. */
  15. public function current();
  16. /**
  17. * Get next element in collection.
  18. *
  19. * @return mixed
  20. */
  21. public function next();
  22. /**
  23. * Return previous element in collection.
  24. * @return mixed
  25. */
  26. public function prev();
  27. /**
  28. * Reset collection (set array to head).
  29. *
  30. * @return mixed Returns first elements value.
  31. */
  32. public function reset();
  33. /**
  34. * Return collection size.
  35. *
  36. * @return int
  37. */
  38. public function len();
  39. /**
  40. * Return the whole colection.
  41. *
  42. * @return array
  43. */
  44. public function all();
  45. /**
  46. * Get element by index key.
  47. *
  48. * @param mixed $idx Index key.
  49. * @return mixed
  50. */
  51. public function by_key($idx);
  52. /**
  53. * Copy collection
  54. *
  55. * @return Colletion
  56. */
  57. public function copy();
  58. /**
  59. * Limit until in collection
  60. *
  61. * @param int $lim Maximum entries returned
  62. * @return Collection
  63. */
  64. public function limit(int $lim);
  65. /**
  66. * Get from offset collection
  67. *
  68. * @param int $off Offset from in collection
  69. * @return Collection
  70. */
  71. public function offset(int $off);
  72. /**
  73. * Reverse the collection
  74. *
  75. * @return Collection
  76. */
  77. public function reverse();
  78. /**
  79. * Sort collection
  80. *
  81. * @return Collection
  82. */
  83. public function sort(callable $f);
  84. }
  85. }