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

    }