ShippingMethodFormatter.php 778 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\InstantPurchase\Model\Ui;
  7. use Magento\Quote\Api\Data\ShippingMethodInterface;
  8. /**
  9. * Ship[ping method string presentation.
  10. *
  11. * @api May be used for pluginization.
  12. * @since 100.2.0
  13. */
  14. class ShippingMethodFormatter
  15. {
  16. /**
  17. * @param ShippingMethodInterface $shippingMethod
  18. * @return string
  19. * @since 100.2.0
  20. */
  21. public function format(ShippingMethodInterface $shippingMethod) : string
  22. {
  23. $data = [
  24. $shippingMethod->getCarrierTitle(),
  25. $shippingMethod->getMethodTitle(),
  26. ];
  27. $data = array_filter($data);
  28. $formatted = join(' - ', $data);
  29. return $formatted;
  30. }
  31. }