PasswordMixedCaseValidator   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
eloc 4
dl 0
loc 10
c 0
b 0
f 0
ccs 0
cts 6
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A validate() 0 7 3
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