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 (#152)
by joseph
17:58
created

EntityDataValidatorFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 43
ccs 0
cts 11
cp 0
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A buildEntityDataValidator() 0 8 1
1
<?php declare(strict_types=1);
2
3
namespace EdmondsCommerce\DoctrineStaticMeta\Entity\Validation;
4
5
use EdmondsCommerce\DoctrineStaticMeta\Entity\Interfaces\Validation\EntityDataValidatorInterface;
6
use Symfony\Component\Validator\Mapping\Cache\DoctrineCache;
7
use Symfony\Component\Validator\Validation;
8
9
class EntityDataValidatorFactory
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
     * Build an EntityDataValidatorInterface
40
     *
41
     * @return EntityDataValidatorInterface
42
     * @SuppressWarnings(PHPMD.StaticAccess)
43
     */
44
    public function buildEntityDataValidator(): EntityDataValidatorInterface
45
    {
46
        $builder = Validation::createValidatorBuilder();
47
        $builder->addMethodMapping(self::METHOD_LOAD_VALIDATOR_META_DATA);
48
        $builder->setMetadataCache($this->doctrineCache);
49
        $validator = $builder->getValidator();
50
51
        return new EntityDataValidator($validator);
52
    }
53
}
54