<?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\EnergyConsumption;

use UnexpectedValueException;

/**
 * The unit of the energy consumption.
 *
 * Protobuf type <code>google.shopping.merchant.products.v1.ProductAttributes.EnergyConsumption.Unit</code>
 */
class Unit
{
    /**
     * Unspecified unit.
     *
     * Generated from protobuf enum <code>UNIT_UNSPECIFIED = 0;</code>
     */
    const UNIT_UNSPECIFIED = 0;
    /**
     * Kilowatt hours per 100 kilometers.
     *
     * Generated from protobuf enum <code>KWHPER100KM = 1;</code>
     */
    const KWHPER100KM = 1;

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

    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);
    }
}

