public static function isValid($value)
    {
        if (__CLASS__ === get_called_class()) {
            throw new \RuntimeException('Cannot call isValid() on ' . __CLASS__);
        }

        $reflectionClass = new \ReflectionClass(get_called_class());
        $validValues = $reflectionClass->getConstants();

        if (static::isBitFlag()) {
            $bitFlagAllOn = 0;

            foreach ($validValues as $validValue) {
                $bitFlagAllOn |= $validValue;
            }

            return ($value | $bitFlagAllOn) === $bitFlagAllOn;
        }

        return in_array($value, $validValues, true);
    }
public static function isValid($value)
    {
        if (__CLASS__ === get_called_class()) {
            throw new \RuntimeException('Cannot call isValid() on ' . __CLASS__);
        }

        $reflectionClass = new \ReflectionClass(get_called_class());
        $validValues = $reflectionClass->getConstants();

        if (static::isBitFlag()) {
            $bitFlagAllOn = 0;

            foreach ($validValues as $validValue) {
                $bitFlagAllOn |= $validValue;
            }

            return ($value | $bitFlagAllOn) === $bitFlagAllOn;
        }

        return in_array($value, $validValues, true);
    }
public static function isValid ( $ value ) { if ( __CLASS__ === get_called_class ( ) ) { throw new \ RuntimeException ( 'Cannot call isValid() on ' . __CLASS__ ) ; } $ reflectionClass = new \ ReflectionClass ( get_called_class ( ) ) ; $ validValues = $ reflectionClass -> getConstants ( ) ; if ( static :: isBitFlag ( ) ) { $ bitFlagAllOn = 0 ; foreach ( $ validValues as $ validValue ) { $ bitFlagAllOn |= $ validValue ; } return ( $ value | $ bitFlagAllOn ) === $ bitFlagAllOn ; } return in_array ( $ value , $ validValues , true ) ; }
Checks if the value is valid according to the enumeration.

@param mixed $value
@return bool
@throws \RuntimeException
Checks if the value is valid according to the enumeration .