GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Password   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 21
c 1
b 0
f 0
dl 0
loc 53
ccs 21
cts 21
cp 1
rs 10
wmc 9

2 Methods

Rating   Name   Duplication   Size   Complexity  
B guard() 0 32 8
A createFromString() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace DBUnt1tled\VO\VObjects\Person;
6
7
use DBUnt1tled\VO\Exception\InvalidVOArgumentException;
8
use DBUnt1tled\VO\VObjects\Scalar\Strings;
9
use DBUnt1tled\VO\VObjects\ValueObjectComplex;
10
use DBUnt1tled\VO\VObjects\ValueObjectInterface;
11
12
class Password extends ValueObjectComplex
13
{
14
    public const PASSWORD_MIN_LENGTH = 8;
15
    public const PASSWORD_MAX_LENGTH = 20;
16
17
    /**
18
     * @param mixed $value
19
     * @param mixed ...$other
20
     * @throws \ReflectionException
21
     */
22 2
    public function guard($value, ...$other): void
23
    {
24 2
        parent::guard($value);
25
        /** @var ValueObjectInterface $value*/
26 2
        $pwd = $value->getValue();
27 2
        $error = '';
28 2
        if (mb_strlen($pwd) < 8) {
29 1
            $error .= 'Password too short!';
30
        }
31
32 2
        if (mb_strlen($pwd) > 20) {
33 1
            $error .= "Password too long!\n";
34
        }
35
36 2
        if (!preg_match('#[\d]+#', $pwd)) {
37 1
            $error .= "Password must include at least one number!\n";
38
        }
39
40 2
        if (!preg_match('#[a-z]+#', $pwd)) {
41 1
            $error .= "Password must include at least one letter!\n";
42
        }
43
44 2
        if (!preg_match('#[A-Z]+#', $pwd)) {
45 1
            $error .= "Password must include at least one CAPS!\n";
46
        }
47
48 2
        if (!preg_match('#\W+#', $pwd)) {
49 1
            $error .= "Password must include at least one symbol!\n";
50
        }
51
52 2
        if ($error !== '') {
53 1
            throw new InvalidVOArgumentException($error, $value);
54
        }
55 1
    }
56
57
    /**
58
     * @param string $value
59
     * @return Password
60
     * @throws \ReflectionException
61
     */
62 2
    public static function createFromString(string $value): self
63
    {
64 2
        return new static(new Strings($value));
65
    }
66
}
67