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
21:14
created

ValidatorFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 15
c 1
b 0
f 0
dl 0
loc 27
ccs 13
cts 13
cp 1
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
class ValidatorFactory
14
{
15
    private $defaultValidator;
16
    private $defaultTranslator;
17
    private $constraintValidatorFactory;
18
19 131
    public function __construct(?ValidatorInterface $validator, ConstraintValidatorFactoryInterface $constraintValidatorFactory, ?TranslatorInterface $translator)
20
    {
21 131
        $this->defaultValidator = $validator;
22 131
        $this->defaultTranslator = $translator;
23 131
        $this->constraintValidatorFactory = $constraintValidatorFactory;
24 131
    }
25
26 8
    public function createValidator(MetadataFactory $metadataFactory): ValidatorInterface
27
    {
28 8
        $builder = Validation::createValidatorBuilder()
29 8
            ->setMetadataFactory($metadataFactory)
30 8
            ->setConstraintValidatorFactory($this->constraintValidatorFactory)
31
        ;
32
33 8
        if (null !== $this->defaultTranslator) {
34
            $builder
35 8
                ->setTranslator($this->defaultTranslator)
0 ignored issues
show
Bug introduced by
$this->defaultTranslator of type Symfony\Contracts\Translation\TranslatorInterface is incompatible with the type Symfony\Component\Translation\TranslatorInterface expected by parameter $translator of Symfony\Component\Valida...uilder::setTranslator(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

35
                ->setTranslator(/** @scrutinizer ignore-type */ $this->defaultTranslator)
Loading history...
36 8
                ->setTranslationDomain('validators');
37
        }
38
39 8
        return $builder->getValidator();
40
    }
41
}
42