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.

ComplexifyValidator::validate()   B
last analyzed

Complexity

Conditions 4
Paths 3

Size

Total Lines 22
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 22
rs 8.9197
cc 4
eloc 12
nc 3
nop 2
1
<?php
2
3
4
namespace Lightmaker\ComplexifyBundle\Validator\Constraints;
5
6
use Symfony\Component\Validator\Constraint;
7
use Symfony\Component\Validator\ConstraintValidator;
8
use Complexify\Complexify as PhpComplexify;
9
10
11
/**
12
 * Class ComplexifyValidator
13
 *
14
 * @package Lightmaker\ComplexifyBundle\Validator\Constraints
15
 */
16
class ComplexifyValidator extends ConstraintValidator
17
{
18
    /**
19
     * @param mixed                 $password
20
     * @param Complexify|Constraint $constraint
21
     */
22
    public function validate($password, Constraint $constraint)
23
    {
24
25
        if (!is_null($password) && !empty($password)) {
26
            $check = new PhpComplexify(
27
                array(
28
                    $constraint->minimumChars,
29
                    $constraint->strengthScaleFactor,
30
                    $constraint->bannedPasswords,
31
                    $constraint->banMode,
32
                    $constraint->encoding,
33
                )
34
            );
35
36
            $result = $check->evaluateSecurity($password);
37
38
            if (!$result->valid) {
39
                $this->context->addViolation($constraint->message);
40
            }
41
        }
42
43
    }
44
45
}
46