Completed
Push — master ( 83241a...8e03fe )
by Anthony
03:35
created

PasswordMixedCaseValidator::validate()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 8
c 0
b 0
f 0
ccs 0
cts 7
cp 0
rs 9.4285
cc 3
eloc 4
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