PasswordMixedCaseValidator::validate()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 7
c 0
b 0
f 0
ccs 0
cts 6
cp 0
rs 10
cc 3
nc 2
nop 1
crap 12
1
<?php
2
declare(strict_types=1);
3
4
namespace Porthou\Password\Validators;
5
6
use Porthou\Password\PasswordException;
7
use Porthou\Password\Validator;
8
9
class PasswordMixedCaseValidator implements Validator
10
{
11
    /** {@inheritdoc} */
12
    public function validate(string $password): bool
13
    {
14
        if ($password !== mb_strtolower($password) && $password !== mb_strtoupper($password)) {
15
            return true;
16
        }
17
18
        throw new PasswordException('Passwords must be a mixture of upper and lower case.');
19
    }
20
}
21