public function alphaNum($subject, string $case = '') : bool
    {
        if ($subject === null) {
            return false;
        }
        $v = '' . $subject;
        if ($v === '') {
            return false;
        }
        switch ($case) {
            case 'lower':
                $regex = '/^[a-z\d]+$/';
                break;
            case 'upper':
                $regex = '/^[A-Z\d]+$/';
                break;
            default:
                $regex = '/^[a-zA-Z\d]+$/';
                break;
        }
        // ctype_... is no good for ASCII-only check, if PHP and server locale
        // is set to something non-English.
        return !!preg_match($regex, $v);
    }
public function alphaNum($subject, string $case = '') : bool
    {
        if ($subject === null) {
            return false;
        }
        $v = '' . $subject;
        if ($v === '') {
            return false;
        }
        switch ($case) {
            case 'lower':
                $regex = '/^[a-z\d]+$/';
                break;
            case 'upper':
                $regex = '/^[A-Z\d]+$/';
                break;
            default:
                $regex = '/^[a-zA-Z\d]+$/';
                break;
        }
        // ctype_... is no good for ASCII-only check, if PHP and server locale
        // is set to something non-English.
        return !!preg_match($regex, $v);
    }
public function alphaNum ( $ subject , string $ case = '' ) : bool { if ( $ subject === null ) { return false ; } $ v = '' . $ subject ; if ( $ v === '' ) { return false ; } switch ( $ case ) { case 'lower' : $ regex = '/^[a-z\d]+$/' ; break ; case 'upper' : $ regex = '/^[A-Z\d]+$/' ; break ; default : $ regex = '/^[a-zA-Z\d]+$/' ; break ; } // ctype_... is no good for ASCII-only check, if PHP and server locale // is set to something non-English. return ! ! preg_match ( $ regex , $ v ) ; }
ASCII alphanumeric.

@see Validate::string()

@param mixed $subject
Checked stringified.
@param string $case
Values: lower|upper, otherwise ignored.

@return bool
False on empty.
ASCII alphanumeric .