public static function validate(string $key) : bool
    {
        $le = strlen($key);
        if ($le < static::VALID_LENGTH_MIN || $le > static::VALID_LENGTH_MAX) {
            return false;
        }
        if ($key{0} === '-') {
            return false;
        }
        // Faster than a regular expression.
        // Prefix letter to make key without any alphanum pass.
        return !!ctype_alnum('A' . str_replace(static::VALID_NON_ALPHANUM, '', $key));
    }
public static function validate(string $key) : bool
    {
        $le = strlen($key);
        if ($le < static::VALID_LENGTH_MIN || $le > static::VALID_LENGTH_MAX) {
            return false;
        }
        if ($key{0} === '-') {
            return false;
        }
        // Faster than a regular expression.
        // Prefix letter to make key without any alphanum pass.
        return !!ctype_alnum('A' . str_replace(static::VALID_NON_ALPHANUM, '', $key));
    }
public static function validate ( string $ key ) : bool { $ le = strlen ( $ key ) ; if ( $ le < static :: VALID_LENGTH_MIN || $ le > static :: VALID_LENGTH_MAX ) { return false ; } if ( $ key { 0 } === '-' ) { return false ; } // Faster than a regular expression. // Prefix letter to make key without any alphanum pass. return ! ! ctype_alnum ( 'A' . str_replace ( static :: VALID_NON_ALPHANUM , '' , $ key ) ) ; }
Checks that length and content is legal.

First char cannot be hyphen, because that could break CLI interaction.

@param string $key

@return bool
Checks that length and content is legal .