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

Completed
Pull Request — master (#536)
by
unknown
20:27
created

ValidatorFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 84.62%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 15
c 1
b 0
f 0
dl 0
loc 27
ccs 11
cts 13
cp 0.8462
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A createValidator() 0 14 2
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
/**
14
 * ValidatorFactory
15
 *
16
 * @author Timur Murtukov <[email protected]>
17
 */
18
class ValidatorFactory
19
{
20
    private $defaultValidator;
21
    private $defaultTranslator;
22
    private $constraintValidatorFactory;
23
24 123
    public function __construct(?ValidatorInterface $validator, ConstraintValidatorFactoryInterface $constraintValidatorFactory, ?TranslatorInterface $translator)
25
    {
26 123
        $this->defaultValidator = $validator;
27 123
        $this->defaultTranslator = $translator;
28 123
        $this->constraintValidatorFactory = $constraintValidatorFactory;
29 123
    }
30
31 1
    public function createValidator(MetadataFactory $metadataFactory): ValidatorInterface
32
    {
33 1
        $builder = Validation::createValidatorBuilder()
34 1
            ->setMetadataFactory($metadataFactory)
35 1
            ->setConstraintValidatorFactory($this->constraintValidatorFactory)
36
        ;
37
38 1
        if (null !== $this->defaultTranslator) {
39
            $builder
40
                ->setTranslator($this->defaultTranslator)
41
                ->setTranslationDomain('validators');
42
        }
43
44 1
        return $builder->getValidator();
45
    }
46
}
47