EventList.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /**
  3. * Refer to LICENSE.txt distributed with the Temando Shipping module for notice of license
  4. */
  5. namespace Temando\Shipping\Sync;
  6. /**
  7. * Temando Event Stack
  8. *
  9. * @package Temando\Shipping\Sync
  10. * @author Benjamin Heuer <benjamin.heuer@netresearch.de>
  11. * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
  12. * @link http://www.temando.com/
  13. */
  14. class EventList extends \ArrayIterator
  15. {
  16. /**
  17. * @param string[] $eventIds
  18. *
  19. * @return static
  20. */
  21. public static function fromArray(array $eventIds)
  22. {
  23. $events = array_combine($eventIds, $eventIds);
  24. return new static($events);
  25. }
  26. /**
  27. * @param string $eventId
  28. *
  29. * @return void
  30. */
  31. public function addEvent($eventId)
  32. {
  33. $this->offsetSet($eventId, $eventId);
  34. }
  35. /**
  36. * @param string $eventId
  37. *
  38. * @return void
  39. */
  40. public function removeEvent($eventId)
  41. {
  42. $this->offsetUnset($eventId);
  43. }
  44. /**
  45. * @param string $eventId
  46. *
  47. * @return bool
  48. */
  49. public function hasEvent($eventId)
  50. {
  51. return $this->offsetExists($eventId);
  52. }
  53. }