Alphanum   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 2
c 1
b 0
f 1
dl 0
loc 12
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A isValid() 0 3 1
1
<?php
2
3
namespace Kontrolio\Rules\Core;
4
5
use Kontrolio\Rules\AbstractRule;
6
7
/**
8
 * Validation rule for alphanumeric characters.
9
 *
10
 * @package Kontrolio\Rules\Core
11
 */
12
class Alphanum extends AbstractRule
13
{
14
    /**
15
     * Validates input.
16
     *
17
     * @param mixed $input
18
     *
19
     * @return bool
20
     */
21
    public function isValid($input = null)
22
    {
23
        return (bool) preg_match('/^([a-z0-9])+$/i', $input);
0 ignored issues
show
Bug introduced by
It seems like $input can also be of type null; however, parameter $subject of preg_match() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

23
        return (bool) preg_match('/^([a-z0-9])+$/i', /** @scrutinizer ignore-type */ $input);
Loading history...
24
    }
25
}
26