<?php
 
 
 

namespace PhpWA\Protocol\Proto\Message\CallLogMessage;

use UnexpectedValueException;




class CallOutcome
{
    


    const CONNECTED = 0;
    


    const MISSED = 1;
    


    const FAILED = 2;
    


    const REJECTED = 3;
    


    const ACCEPTED_ELSEWHERE = 4;
    


    const ONGOING = 5;
    


    const SILENCED_BY_DND = 6;
    


    const SILENCED_UNKNOWN_CALLER = 7;

    private static $valueToName = [
        self::CONNECTED => 'CONNECTED',
        self::MISSED => 'MISSED',
        self::FAILED => 'FAILED',
        self::REJECTED => 'REJECTED',
        self::ACCEPTED_ELSEWHERE => 'ACCEPTED_ELSEWHERE',
        self::ONGOING => 'ONGOING',
        self::SILENCED_BY_DND => 'SILENCED_BY_DND',
        self::SILENCED_UNKNOWN_CALLER => 'SILENCED_UNKNOWN_CALLER',
    ];

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

