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

use UnexpectedValueException;

/**
 * [Condition](https://support.google.com/merchants/answer/6324469) or state
 * of the item.
 *
 * Protobuf type <code>google.shopping.merchant.products.v1.Condition</code>
 */
class Condition
{
    /**
     * Default value. This value is unused.
     *
     * Generated from protobuf enum <code>CONDITION_UNSPECIFIED = 0;</code>
     */
    const CONDITION_UNSPECIFIED = 0;
    /**
     * Brand new, original, unopened packaging.
     *
     * Generated from protobuf enum <code>NEW = 1;</code>
     */
    const PBNEW = 1;
    /**
     * Previously used, original packaging opened or missing.
     *
     * Generated from protobuf enum <code>USED = 2;</code>
     */
    const USED = 2;
    /**
     * Professionally restored to working order, comes with a warranty, may or
     * may not have the original packaging.
     *
     * Generated from protobuf enum <code>REFURBISHED = 3;</code>
     */
    const REFURBISHED = 3;

    private static $valueToName = [
        self::CONDITION_UNSPECIFIED => 'CONDITION_UNSPECIFIED',
        self::PBNEW => 'NEW',
        self::USED => 'USED',
        self::REFURBISHED => 'REFURBISHED',
    ];

    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)) {
            $pbconst =  __CLASS__. '::PB' . strtoupper($name);
            if (!defined($pbconst)) {
                throw new UnexpectedValueException(sprintf(
                        'Enum %s has no value defined for name %s', __CLASS__, $name));
            }
            return constant($pbconst);
        }
        return constant($const);
    }
}

