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

ValidatorFactory::getValidator()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 0
cts 5
cp 0
rs 9.6666
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 1
crap 6
1
<?php
2
/**
3
 * @package: Chapi
4
 *
5
 * @author:  msiebeneicher
6
 * @since:   2016-11-10
7
 *
8
 */
9
10
namespace Chapi\Service\JobValidator;
11
12
13
use Chapi\Service\JobValidator\PropertyValidator\Command;
14
use Chapi\Service\JobValidator\PropertyValidator\Constraints;
15
use Chapi\Service\JobValidator\PropertyValidator\Container;
16
use Chapi\Service\JobValidator\PropertyValidator\Epsilon;
17
use Chapi\Service\JobValidator\PropertyValidator\IsArray;
18
use Chapi\Service\JobValidator\PropertyValidator\IsBoolean;
19
use Chapi\Service\JobValidator\PropertyValidator\JobName;
20
use Chapi\Service\JobValidator\PropertyValidator\NotEmpty;
21
use Chapi\Service\JobValidator\PropertyValidator\Retries;
22
use Chapi\Service\JobValidator\PropertyValidator\Schedule;
23
use Symfony\Component\DependencyInjection\ContainerInterface;
24
25
class ValidatorFactory implements ValidatorFactoryInterface
26
{
27
    /**
28
     * @var string[]
29
     */
30
    private static $aValidatorMap = [
31
        self::NOT_EMPTY_VALIDATOR => NotEmpty::DIC_NAME,
32
        self::NAME_VALIDATOR => JobName::DIC_NAME,
33
        self::EPSILON_VALIDATOR => Epsilon::DIC_NAME,
34
        self::BOOLEAN_VALIDATOR => IsBoolean::DIC_NAME,
35
        self::SCHEDULE_VALIDATOR => Schedule::DIC_NAME,
36
        self::ARRAY_VALIDATOR => IsArray::DIC_NAME,
37
        self::RETRY_VALIDATOR => Retries::DIC_NAME,
38
        self::CONSTRAINTS_VALIDATOR => Constraints::DIC_NAME,
39
        self::CONTAINER_VALIDATOR => Container::DIC_NAME,
40
        self::COMMAND_VALIDATOR => Command::DIC_NAME,
41
    ];
42
43
    /**
44
     * @var ContainerInterface
45
     */
46
    private $oServiceContainer;
47
48
    /**
49
     * ValidatorFactory constructor.
50
     * @param ContainerInterface $oServiceContainer
51
     */
52
    public function __construct(ContainerInterface $oServiceContainer)
53
    {
54
        $this->oServiceContainer = $oServiceContainer;
55
    }
56
57
    /**
58
     * @param int $iValidator
59
     * @return PropertyValidatorInterface
60
     */
61
    public function getValidator($iValidator)
62
    {
63
        if (!isset(self::$aValidatorMap[$iValidator]))
64
        {
65
            throw new \InvalidArgumentException(sprintf('Unknown validator type "%s"', $iValidator));
66
        }
67
        
68
        return $this->oServiceContainer->get(self::$aValidatorMap[$iValidator]);
69
    }
70
}