<?php
# Generated by the protocol buffer compiler.  DO NOT EDIT!
# source: google/shopping/type/types.proto

namespace Google\Shopping\Type\Weight;

use UnexpectedValueException;

/**
 * The weight unit.
 *
 * Protobuf type <code>google.shopping.type.Weight.WeightUnit</code>
 */
class WeightUnit
{
    /**
     * unit unspecified
     *
     * Generated from protobuf enum <code>WEIGHT_UNIT_UNSPECIFIED = 0;</code>
     */
    const WEIGHT_UNIT_UNSPECIFIED = 0;
    /**
     * lb unit.
     *
     * Generated from protobuf enum <code>POUND = 1;</code>
     */
    const POUND = 1;
    /**
     * kg unit.
     *
     * Generated from protobuf enum <code>KILOGRAM = 2;</code>
     */
    const KILOGRAM = 2;

    private static $valueToName = [
        self::WEIGHT_UNIT_UNSPECIFIED => 'WEIGHT_UNIT_UNSPECIFIED',
        self::POUND => 'POUND',
        self::KILOGRAM => 'KILOGRAM',
    ];

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

// Adding a class alias for backwards compatibility with the previous class name.
class_alias(WeightUnit::class, \Google\Shopping\Type\Weight_WeightUnit::class);

