<?php
 
 
 

namespace PhpWA\Protocol\Proto\CallLogRecord;

use UnexpectedValueException;




class CallResult
{
    


    const CONNECTED = 0;
    


    const REJECTED = 1;
    


    const CANCELLED = 2;
    


    const ACCEPTEDELSEWHERE = 3;
    


    const MISSED = 4;
    


    const INVALID = 5;
    


    const UNAVAILABLE = 6;
    


    const UPCOMING = 7;
    


    const FAILED = 8;
    


    const ABANDONED = 9;
    


    const ONGOING = 10;

    private static $valueToName = [
        self::CONNECTED => 'CONNECTED',
        self::REJECTED => 'REJECTED',
        self::CANCELLED => 'CANCELLED',
        self::ACCEPTEDELSEWHERE => 'ACCEPTEDELSEWHERE',
        self::MISSED => 'MISSED',
        self::INVALID => 'INVALID',
        self::UNAVAILABLE => 'UNAVAILABLE',
        self::UPCOMING => 'UPCOMING',
        self::FAILED => 'FAILED',
        self::ABANDONED => 'ABANDONED',
        self::ONGOING => 'ONGOING',
    ];

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

