Value.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 Value implements ArrayInterface
  10. {
  11. private const MODE_DISTANCE = 'distance';
  12. private const MODE_TIME = 'time';
  13. /**
  14. * Options getter
  15. *
  16. * @return array
  17. */
  18. public function toOptionArray()
  19. {
  20. return [
  21. ['value' => self::MODE_DISTANCE, 'label' => __('Distance')],
  22. ['value' => self::MODE_TIME, 'label' => __('Time to destination')],
  23. ];
  24. }
  25. /**
  26. * Get options in "key-value" format
  27. *
  28. * @return array
  29. */
  30. public function toArray()
  31. {
  32. $options = $this->toOptionArray();
  33. $return = [];
  34. foreach ($options as $option) {
  35. $return[$option['value']] = $option['label'];
  36. }
  37. return $return;
  38. }
  39. }