<?php
# Generated by the protocol buffer compiler.  DO NOT EDIT!
# source: google/shopping/merchant/products/v1/products_common.proto

namespace Google\Shopping\Merchant\Products\V1\ProductAttributes\Mileage;

use UnexpectedValueException;

/**
 * The unit of the mileage.
 *
 * Protobuf type <code>google.shopping.merchant.products.v1.ProductAttributes.Mileage.Unit</code>
 */
class Unit
{
    /**
     * Unspecified unit.
     *
     * Generated from protobuf enum <code>UNIT_UNSPECIFIED = 0;</code>
     */
    const UNIT_UNSPECIFIED = 0;
    /**
     * Miles.
     *
     * Generated from protobuf enum <code>MILES = 1;</code>
     */
    const MILES = 1;
    /**
     * Kilometers.
     *
     * Generated from protobuf enum <code>KM = 2;</code>
     */
    const KM = 2;

    private static $valueToName = [
        self::UNIT_UNSPECIFIED => 'UNIT_UNSPECIFIED',
        self::MILES => 'MILES',
        self::KM => 'KM',
    ];

    public static function name($value)
    {
        if (!isset(self::$valueToName[$value])) {
            throw new UnexpectedValueException(sprintf(
                    'Enum %s has no name defined for value %s', __CLASS__, $value));
        }
        return self::$valueToName[$value];
    }


    public static function value($name)
    {
        $const = __CLASS__ . '::' . strtoupper($name);
        if (!defined($const)) {
            throw new UnexpectedValueException(sprintf(
                    'Enum %s has no value defined for name %s', __CLASS__, $name));
        }
        return constant($const);
    }
}

