<?php
 
 
 

namespace PhpWA\Protocol\Proto;

use UnexpectedValueException;




class CollectionName
{
    


    const COLLECTION_NAME_UNKNOWN = 0;
    


    const REGULAR = 1;
    


    const REGULAR_LOW = 2;
    


    const REGULAR_HIGH = 3;
    


    const CRITICAL_BLOCK = 4;
    


    const CRITICAL_UNBLOCK_LOW = 5;

    private static $valueToName = [
        self::COLLECTION_NAME_UNKNOWN => 'COLLECTION_NAME_UNKNOWN',
        self::REGULAR => 'REGULAR',
        self::REGULAR_LOW => 'REGULAR_LOW',
        self::REGULAR_HIGH => 'REGULAR_HIGH',
        self::CRITICAL_BLOCK => 'CRITICAL_BLOCK',
        self::CRITICAL_UNBLOCK_LOW => 'CRITICAL_UNBLOCK_LOW',
    ];

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

