Mode.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. declare(strict_types=1);
  7. namespace Magento\InventoryDistanceBasedSourceSelectionAdminUi\Model\Config\Source\GoogleDistanceProvider;
  8. use Magento\Framework\Option\ArrayInterface;
  9. class Mode implements ArrayInterface
  10. {
  11. private const MODE_DRIVING = 'driving';
  12. private const MODE_WALKING = 'walking';
  13. private const MODE_BICYCLING = 'bicycling';
  14. /**
  15. * Options getter
  16. *
  17. * @return array
  18. */
  19. public function toOptionArray()
  20. {
  21. return [
  22. ['value' => self::MODE_DRIVING, 'label' => __('Driving')],
  23. ['value' => self::MODE_WALKING, 'label' => __('Walking')],
  24. ['value' => self::MODE_BICYCLING, 'label' => __('Bicycling')]
  25. ];
  26. }
  27. /**
  28. * Get options in "key-value" format
  29. *
  30. * @return array
  31. */
  32. public function toArray()
  33. {
  34. $options = $this->toOptionArray();
  35. $return = [];
  36. foreach ($options as $option) {
  37. $return[$option['value']] = $option['label'];
  38. }
  39. return $return;
  40. }
  41. }