Collection.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4. * This file is part of the Geocoder package.
  5. * For the full copyright and license information, please view the LICENSE
  6. * file that was distributed with this source code.
  7. *
  8. * @license MIT License
  9. */
  10. namespace Geocoder;
  11. use Geocoder\Exception\CollectionIsEmpty;
  12. use Geocoder\Exception\OutOfBounds;
  13. /**
  14. * This is the interface that is always return from a Geocoder.
  15. *
  16. * @author William Durand <william.durand1@gmail.com>
  17. * @author Tobias Nyholm <tobias.nyholm@gmail.com>
  18. */
  19. interface Collection extends \IteratorAggregate, \Countable
  20. {
  21. /**
  22. * @return Location
  23. *
  24. * @throws CollectionIsEmpty
  25. */
  26. public function first(): Location;
  27. /**
  28. * @return bool
  29. */
  30. public function isEmpty(): bool;
  31. /**
  32. * @return Location[]
  33. */
  34. public function slice(int $offset, int $length = null);
  35. /**
  36. * @return bool
  37. */
  38. public function has(int $index): bool;
  39. /**
  40. * @return Location
  41. *
  42. * @throws OutOfBounds
  43. */
  44. public function get(int $index): Location;
  45. /**
  46. * @return Location[]
  47. */
  48. public function all(): array;
  49. }