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
Branch fixTravis (38feec)
by joseph
03:19
created

ValidateTrait::loadPropertyValidatorMetaData()   B

Complexity

Conditions 5
Paths 14

Size

Total Lines 20
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 14
nc 14
nop 1
dl 0
loc 20
rs 8.8571
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace EdmondsCommerce\DoctrineStaticMeta\Entity\Traits;
4
5
use EdmondsCommerce\DoctrineStaticMeta\Entity\Interfaces\ValidateInterface;
6
use EdmondsCommerce\DoctrineStaticMeta\Exception\DoctrineStaticMetaException;
7
use Symfony\Component\Validator\ConstraintViolationListInterface;
8
use Symfony\Component\Validator\Mapping\ClassMetadata as ValidatorClassMetaData;
9
use Symfony\Component\Validator\Validator\ValidatorInterface;
10
use Symfony\Component\Validator\Mapping\ClassMetadata;
11
12
trait ValidateTrait
13
{
14
    protected $needsValidating = false;
15
16
    /**
17
     * @param ValidatorClassMetaData $metadata
18
     *
19
     * @throws DoctrineStaticMetaException
20
     */
21
    public static function loadValidatorMetaData(ValidatorClassMetaData $metadata): void
22
    {
23
        static::$reflectionClass = $metadata->getReflectionClass();
0 ignored issues
show
Bug Best Practice introduced by
The property reflectionClass does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
24
        static::loadPropertyValidatorMetaData($metadata);
25
    }
26
27
    public static function getPropertyValidatorMetaFor(ClassMetadata $metadata)
28
    {
29
        static::loadValidatorMetaData($metadata);
30
    }
31
32
    /**
33
     * @param ValidatorClassMetaData $metadata
34
     *
35
     * @throws DoctrineStaticMetaException
36
     */
37
    protected static function loadPropertyValidatorMetaData(ValidatorClassMetaData $metadata): void
38
    {
39
        $methodName = '__no_method__';
40
        try {
41
            $staticMethods = static::getStaticMethods();
42
            //now loop through and call them
43
            foreach ($staticMethods as $method) {
44
                $methodName = $method->getName();
45
                if ($methodName === ValidateInterface::METHOD_PREFIX_GET_PROPERTY_VALIDATOR_META) {
46
                    continue;
47
                }
48
                if (0 === stripos($methodName, ValidateInterface::METHOD_PREFIX_GET_PROPERTY_VALIDATOR_META)) {
49
                    static::$methodName($metadata);
50
                }
51
            }
52
        } catch (\Exception $e) {
53
            throw new DoctrineStaticMetaException(
54
                'Exception in '.__METHOD__.'for '
55
                .self::$reflectionClass->getName()."::$methodName\n\n"
56
                .$e->getMessage()
57
            );
58
        }
59
    }
60
61
    public function setValidated()
62
    {
63
        $this->needsValidating = false;
64
        return $this;
65
    }
66
67
    public function setNeedsValidating()
68
    {
69
        $this->needsValidating = true;
70
        return $this;
71
    }
72
73
    public function needsValidating(): bool
74
    {
75
        return $this->needsValidating;
76
    }
77
}
78