Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Passed
Pull Request — master (#564)
by Jérémiah
21:23 queued 06:49
created

ValidatorFactory::createValidator()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 17
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3.0987

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 9
dl 0
loc 17
ccs 7
cts 9
cp 0.7778
rs 9.9666
c 2
b 0
f 0
cc 3
nc 4
nop 1
crap 3.0987
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Overblog\GraphQLBundle\Validator;
6
7
use Overblog\GraphQLBundle\Validator\Mapping\MetadataFactory;
8
use Symfony\Component\Validator\ConstraintValidatorFactoryInterface;
9
use Symfony\Component\Validator\Validation;
10
use Symfony\Component\Validator\Validator\ValidatorInterface;
11
use Symfony\Contracts\Translation\TranslatorInterface;
12
13
class ValidatorFactory
14
{
15
    private $defaultValidator;
16
    private $defaultTranslator;
17
    private $constraintValidatorFactory;
18
19 106
    public function __construct(?ValidatorInterface $validator, ?ConstraintValidatorFactoryInterface $constraintValidatorFactory, ?TranslatorInterface $translator)
20
    {
21 106
        $this->defaultValidator = $validator;
22 106
        $this->defaultTranslator = $translator;
23 106
        $this->constraintValidatorFactory = $constraintValidatorFactory;
24 106
    }
25
26 10
    public function createValidator(MetadataFactory $metadataFactory): ValidatorInterface
27
    {
28 10
        $builder = Validation::createValidatorBuilder()
29 10
            ->setMetadataFactory($metadataFactory)
30
        ;
31
32 10
        if (null !== $this->constraintValidatorFactory) {
33 10
            $builder->setConstraintValidatorFactory($this->constraintValidatorFactory);
34
        }
35
36 10
        if (null !== $this->defaultTranslator) {
37
            $builder
38
                ->setTranslator($this->defaultTranslator)
39
                ->setTranslationDomain('validators');
40
        }
41
42 10
        return $builder->getValidator();
43
    }
44
}
45