DocumentationResponseMapper.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. * Refer to LICENSE.txt distributed with the Temando Shipping module for notice of license
  4. */
  5. namespace Temando\Shipping\Rest\EntityMapper;
  6. use Temando\Shipping\Model\DocumentationInterface;
  7. use Temando\Shipping\Model\DocumentationInterfaceFactory;
  8. use Temando\Shipping\Rest\Response\Fields\Generic\Documentation;
  9. /**
  10. * Map API data to application data object
  11. *
  12. * @package Temando\Shipping\Rest
  13. * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
  14. * @author Christoph Aßmann <christoph.assmann@netresearch.de>
  15. * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
  16. * @link http://www.temando.com/
  17. */
  18. class DocumentationResponseMapper
  19. {
  20. /**
  21. * @var DocumentationInterfaceFactory
  22. */
  23. private $documentationFactory;
  24. /**
  25. * DocumentationResponseMapper constructor.
  26. * @param DocumentationInterfaceFactory $documentationFactory
  27. */
  28. public function __construct(DocumentationInterfaceFactory $documentationFactory)
  29. {
  30. $this->documentationFactory = $documentationFactory;
  31. }
  32. /**
  33. * @param Documentation $apiDoc
  34. * @return DocumentationInterface
  35. */
  36. public function map(Documentation $apiDoc)
  37. {
  38. $documentation = $this->documentationFactory->create(['data' => [
  39. DocumentationInterface::DOCUMENTATION_ID => $apiDoc->getId(),
  40. DocumentationInterface::NAME => $apiDoc->getDescription(),
  41. DocumentationInterface::TYPE => $apiDoc->getType(),
  42. DocumentationInterface::SIZE => $apiDoc->getSize(),
  43. DocumentationInterface::MIME_TYPE => $apiDoc->getMimeType(),
  44. DocumentationInterface::URL => $apiDoc->getUrl(),
  45. ]]);
  46. return $documentation;
  47. }
  48. }