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
Push — master ( 8619f1...53d2ad )
by Ross
52s queued 13s
created

EntityValidatorFactory::getValidatorForEntity()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 2
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace EdmondsCommerce\DoctrineStaticMeta\Entity\Validation;
4
5
use EdmondsCommerce\DoctrineStaticMeta\Entity\Interfaces\Validation\EntityValidatorInterface;
6
use Symfony\Component\Validator\Mapping\Cache\DoctrineCache;
7
use Symfony\Component\Validator\Validation;
8
9
class EntityValidatorFactory
10
{
11
    /**
12
     * The public static method that is called to load the validator meta data
13
     *
14
     * @see https://symfony.com/doc/current/validation.html
15
     *
16
     * @see https://symfony.com/doc/current/components/validator/resources.html#the-staticmethodloader
17
     *
18
     */
19
    public const METHOD_LOAD_VALIDATOR_META_DATA = 'loadValidatorMetadata';
20
21
    /**
22
     * @var DoctrineCache
23
     */
24
    protected $doctrineCache;
25
26
    /**
27
     * ValidatorFactory constructor.
28
     *
29
     * You need to specify the cache driver implementation at the DI level
30
     *
31
     * @param DoctrineCache $doctrineCache
32
     */
33
    public function __construct(DoctrineCache $doctrineCache)
34
    {
35
        $this->doctrineCache = $doctrineCache;
36
    }
37
38
    /**
39
     * @return EntityValidatorInterface
40
     * @SuppressWarnings(PHPMD.StaticAccess)
41
     */
42
    public function getEntityValidator(): EntityValidatorInterface
43
    {
44
        $builder = Validation::createValidatorBuilder();
45
        $builder->addMethodMapping(self::METHOD_LOAD_VALIDATOR_META_DATA);
46
        $builder->setMetadataCache($this->doctrineCache);
47
        $validator       = $builder->getValidator();
48
        $entityValidator = new EntityValidator();
49
        $entityValidator->setValidator($validator);
50
51
        return $entityValidator;
52
    }
53
}
54