EntityProcessorFactory.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. use Temando\Shipping\Model\StreamEventInterface;
  7. use Temando\Shipping\Sync\Exception\EventException;
  8. /**
  9. * Temando Event Processor Factory
  10. *
  11. * @package Temando\Shipping\Sync
  12. * @author Benjamin Heuer <benjamin.heuer@netresearch.de>
  13. * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
  14. * @link http://www.temando.com/
  15. */
  16. class EntityProcessorFactory
  17. {
  18. /**
  19. * @var ShipmentProcessor
  20. */
  21. private $shipmentProcessor;
  22. /**
  23. * EntityEventProcessorFactory constructor.
  24. * @param ShipmentProcessor $shipmentProcessor
  25. */
  26. public function __construct(ShipmentProcessor $shipmentProcessor)
  27. {
  28. $this->shipmentProcessor = $shipmentProcessor;
  29. }
  30. /**
  31. * @param string $entityType
  32. * @return EntityProcessorInterface
  33. * @throws EventException
  34. */
  35. public function get($entityType)
  36. {
  37. switch ($entityType) {
  38. case StreamEventInterface::ENTITY_TYPE_SHIPMENT:
  39. return $this->shipmentProcessor;
  40. default:
  41. throw EventException::unknownEntityType($entityType);
  42. }
  43. }
  44. }