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.

Constraints   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 8
lcom 0
cbo 1
dl 0
loc 38
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A isValid() 0 8 1
B isConstraintsPropertyValid() 0 16 7
1
<?php
2
/**
3
 * @package: chapi
4
 *
5
 * @author:  msiebeneicher
6
 * @since:   2016-11-10
7
 *
8
 */
9
10
11
namespace Chapi\Service\JobValidator\PropertyValidator;
12
13
use Chapi\Entity\Chronos\JobEntity;
14
use Chapi\Entity\JobEntityInterface;
15
use Chapi\Service\JobValidator\PropertyValidatorInterface;
16
17
class Constraints extends AbstractPropertyValidator implements PropertyValidatorInterface
18
{
19
    const DIC_NAME = 'ConstraintsValidator';
20
    const MESSAGE_TEMPLATE = '"%s" contained constraint is not valid. Should be an array with three values.';
21
22
    /**
23
     * @inheritDoc
24
     */
25 3
    public function isValid($property, JobEntityInterface $jobEntity)
26
    {
27 3
        return $this->returnIsValidHelper(
28 3
            $this->isConstraintsPropertyValid($jobEntity->{$property}),
29 3
            $property,
30 3
            self::MESSAGE_TEMPLATE
31
        );
32
    }
33
34
    /**
35
     * @param array $constraints
36
     * @return bool
37
     */
38 3
    private function isConstraintsPropertyValid($constraints)
39
    {
40 3
        if (!is_array($constraints) && !is_null($constraints)) {
41 2
            return false;
42
        }
43
        
44 3
        if (!empty($constraints)) {
45 2
            foreach ($constraints as $constraint) {
46 2
                if (!is_array($constraint) || count($constraint) != 3) {
47 2
                    return false;
48
                }
49
            }
50
        }
51
52 2
        return true;
53
    }
54
}
55