protected static function getModeConstant($value) {
        
        // if the value coming in, is a integer, ensure it is one of the constants
        if (is_int($value)) {

            // it can be the number of colors
            // if it is less than or equal to 16,
            if ($value <= 16) {

                // then it is the simple VT100
                return self::VT100;

            // if it is less than or equal to 256
            } else if ($value <= 256) {

                // then it is the middling xterm like terminal
                return self::XTERM;

            // if it is greater than 256
            } else {

                // then an attempt at the highest colors is made
                return self::RGB;
            }

        }
        // if the value coming in is a string
        else if (is_string($value)) {

            // trim the string
            $value = trim($value);

            // transform to uppercase
            $value = strtoupper($value);

            // make sure it matches one of the constant integer values
            if (in_array($value, self::$constants)) {

                // it is valid, return it
                return $value;

            } else {

                // not a valid string
                return self::XTERM;
            }

        } else {

            // something went wrong, return left
            return self::XTERM;
        }

    }
protected static function getModeConstant($value) {
        
        // if the value coming in, is a integer, ensure it is one of the constants
        if (is_int($value)) {

            // it can be the number of colors
            // if it is less than or equal to 16,
            if ($value <= 16) {

                // then it is the simple VT100
                return self::VT100;

            // if it is less than or equal to 256
            } else if ($value <= 256) {

                // then it is the middling xterm like terminal
                return self::XTERM;

            // if it is greater than 256
            } else {

                // then an attempt at the highest colors is made
                return self::RGB;
            }

        }
        // if the value coming in is a string
        else if (is_string($value)) {

            // trim the string
            $value = trim($value);

            // transform to uppercase
            $value = strtoupper($value);

            // make sure it matches one of the constant integer values
            if (in_array($value, self::$constants)) {

                // it is valid, return it
                return $value;

            } else {

                // not a valid string
                return self::XTERM;
            }

        } else {

            // something went wrong, return left
            return self::XTERM;
        }

    }
protected static function getModeConstant ( $ value ) { // if the value coming in, is a integer, ensure it is one of the constants if ( is_int ( $ value ) ) { // it can be the number of colors // if it is less than or equal to 16, if ( $ value <= 16 ) { // then it is the simple VT100 return self :: VT100 ; // if it is less than or equal to 256 } else if ( $ value <= 256 ) { // then it is the middling xterm like terminal return self :: XTERM ; // if it is greater than 256 } else { // then an attempt at the highest colors is made return self :: RGB ; } } // if the value coming in is a string else if ( is_string ( $ value ) ) { // trim the string $ value = trim ( $ value ) ; // transform to uppercase $ value = strtoupper ( $ value ) ; // make sure it matches one of the constant integer values if ( in_array ( $ value , self :: $ constants ) ) { // it is valid, return it return $ value ; } else { // not a valid string return self :: XTERM ; } } else { // something went wrong, return left return self :: XTERM ; } }
Helper function to take a value and turn it into a valid constant integer value

@param string | int $value
if int -
if it is any other number, it tries to ascertain the mode based on the number of colors
if string -
if it is one of the constants Mode::XTERM, then it returns that mode
it matches the constant names (such as "xterm" or "RGB") case-insensitive, if that
does not work, it defaults to xterm


@return int - the constant or the $default parameter value if something went wrong
Helper function to take a value and turn it into a valid constant integer value