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   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 3
dl 0
loc 30
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B validate() 0 22 4
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