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.
Test Failed
Pull Request — master (#31)
by Ross
09:29
created

ValidateTrait::loadPropertyValidatorMetaData()   B

Complexity

Conditions 5
Paths 14

Size

Total Lines 23
Code Lines 15

Duplication

Lines 23
Ratio 100 %

Importance

Changes 0
Metric Value
dl 23
loc 23
c 0
b 0
f 0
rs 8.5906
cc 5
eloc 15
nc 14
nop 1
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();
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 View Code Duplication
    protected static function loadPropertyValidatorMetaData(ValidatorClassMetaData $metadata): void
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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