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.

PasswordValidator   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 19
rs 10
c 0
b 0
f 0
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A hasSpecialChars() 0 11 4
1
<?php
2
3
declare(strict_types=1);
4
5
namespace LM\AuthAbstractor\Validator;
6
7
/**
8
 * This class contains methods to validate passwords.
9
 */
10
class PasswordValidator
11
{
12
    /**
13
     * Validates that a password contains special characters.
14
     *
15
     * @param string $password The password we want to validate.
16
     * @return bool Whether the password is valid or not.
17
     */
18
    public function hasSpecialChars(string $password): bool
19
    {
20
        switch (preg_match('/[^a-zA-Z0-9]/', $password)) {
21
            case 0:
22
                return false;
23
24
            case 1:
25
                return true;
26
27
            case false:
0 ignored issues
show
Bug Best Practice introduced by
It seems like you are loosely comparing preg_match('/[^a-zA-Z0-9]/', $password) of type integer to the boolean false. If you are specifically checking for 0, consider using something more explicit like === 0 instead.
Loading history...
introduced by
The function implicitly returns null when this case condition does not match. This is incompatible with the type-hinted return boolean. Consider adding a default case to the switch.
Loading history...
28
                throw new Exception();
0 ignored issues
show
Bug introduced by
The type LM\AuthAbstractor\Validator\Exception was not found. Did you mean Exception? If so, make sure to prefix the type with \.
Loading history...
29
        }
30
    }
31
}
32