ShipmentOperationPool.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /**
  3. * Refer to LICENSE.txt distributed with the Temando Shipping module for notice of license
  4. */
  5. namespace Temando\Shipping\Model\Sales\Service;
  6. use Temando\Shipping\Model\Sales\Service\Operation\ShipmentOperationInterface;
  7. /**
  8. * Temando Shipment Operation Pool.
  9. *
  10. * @package Temando\Shipping\Model
  11. * @author Christoph Aßmann <christoph.assmann@netresearch.de>
  12. * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
  13. * @link https://www.temando.com/
  14. */
  15. class ShipmentOperationPool
  16. {
  17. /**
  18. * @var ShipmentOperationInterface[][]
  19. */
  20. private $operations = [];
  21. /**
  22. * ShipmentOperationPool constructor.
  23. * @param Operation\ShipmentOperationInterface[][] $operations
  24. */
  25. public function __construct(array $operations)
  26. {
  27. $this->operations = $operations;
  28. }
  29. /**
  30. * @param string $operationCode
  31. * @return ShipmentOperationInterface[]
  32. */
  33. public function get($operationCode): array
  34. {
  35. if (!isset($this->operations[$operationCode])) {
  36. return [];
  37. }
  38. return $this->operations[$operationCode];
  39. }
  40. }