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.
Completed
Pull Request — master (#61)
by Marc
04:35
created

Constraints   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 42
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 42
ccs 18
cts 18
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 20 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\Service\JobValidator\PropertyValidatorInterface;
15
16
class Constraints extends AbstractPropertyValidator implements PropertyValidatorInterface
17
{
18
    const DIC_NAME = 'ConstraintsValidator';
19
    const MESSAGE_TEMPLATE = '"%s" contained constraint is not valid. Should be an array with three values.';
20
21
    /**
22
     * @inheritDoc
23
     */
24 3
    public function isValid($sProperty, JobEntity $oJobEntity)
25
    {
26 3
        return $this->returnIsValidHelper(
27 3
            $this->isConstraintsPropertyValid($oJobEntity->{$sProperty}),
28 3
            $sProperty,
29
            self::MESSAGE_TEMPLATE
30 3
        );
31
    }
32
33
    /**
34
     * @param array $aConstraints
35
     * @return bool
36
     */
37 3
    private function isConstraintsPropertyValid($aConstraints)
38
    {
39 3
        if (!is_array($aConstraints) && !is_null($aConstraints))
40 3
        {
41 2
            return false;
42
        }
43
        
44 3
        if (!empty($aConstraints))
45 3
        {
46 2
            foreach ($aConstraints as $_aConstraint)
47
            {
48 2
                if (!is_array($_aConstraint) || count($_aConstraint) != 3)
49 2
                {
50 1
                    return false;
51
                }
52 1
            }
53 1
        }
54
55 2
        return true;
56
    }
57
}