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 ( c19cc3...72cdd3 )
by joseph
30:50 queued 27:52
created

UsesPHPMetaDataTrait::getIdField()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
crap 2
1
<?php declare(strict_types=1);
2
3
namespace EdmondsCommerce\DoctrineStaticMeta\Entity\Traits;
4
5
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
6
use Doctrine\ORM\Mapping\ClassMetadata as DoctrineClassMetaData;
7
use EdmondsCommerce\DoctrineStaticMeta\DoctrineStaticMeta;
8
use EdmondsCommerce\DoctrineStaticMeta\Entity\Interfaces\UsesPHPMetaDataInterface;
9
use EdmondsCommerce\DoctrineStaticMeta\Exception\DoctrineStaticMetaException;
10
11
trait UsesPHPMetaDataTrait
12
{
13
14
    /**
15
     * @var DoctrineStaticMeta
16
     */
17
    private static $doctrineStaticMeta;
18
19
    /**
20
     * Loads the class and property meta data in the class
21
     *
22
     * This is the method called by Doctrine to load the meta data
23
     *
24
     * @param DoctrineClassMetaData $metaData
25
     *
26
     * @throws DoctrineStaticMetaException
27
     * @SuppressWarnings(PHPMD.StaticAccess)
28
     */
29
    public static function loadMetadata(DoctrineClassMetaData $metaData): void
30
    {
31
        try {
32
            self::getDoctrineStaticMeta()->setMetaData($metaData)->buildMetaData();
33
        } catch (\Exception $e) {
34
            throw new DoctrineStaticMetaException(
35
                'Exception in ' . __METHOD__ . ': ' . $e->getMessage(),
36
                $e->getCode(),
37
                $e
38
            );
39
        }
40
    }
41
42
    /**
43
     * @return DoctrineStaticMeta
44
     * @throws \ReflectionException
45
     */
46
    public static function getDoctrineStaticMeta(): DoctrineStaticMeta
47
    {
48
        if (null === self::$doctrineStaticMeta) {
49
            self::$doctrineStaticMeta = new DoctrineStaticMeta(self::class);
50
        }
51
52
        return self::$doctrineStaticMeta;
53
    }
54
55
    /**
56
     * In the class itself, we need to specify the repository class name
57
     *
58
     * @param ClassMetadataBuilder $builder
59
     *
60
     * @return mixed
61
     */
62
    abstract protected static function setCustomRepositoryClass(ClassMetadataBuilder $builder);
63
64
65
    /**
66
     * Find and run all init methods
67
     * - defined in relationship traits and generally to init ArrayCollection properties
68
     *
69
     * @throws \ReflectionException
70
     */
71
    protected function runInitMethods(): void
72
    {
73
        $reflectionClass = self::getDoctrineStaticMeta()->getReflectionClass();
74
        $methods         = $reflectionClass->getMethods(\ReflectionMethod::IS_PRIVATE);
75
        foreach ($methods as $method) {
76
            if ($method instanceof \ReflectionMethod) {
77
                $method = $method->getName();
78
            }
79
            if (\ts\stringContains($method, UsesPHPMetaDataInterface::METHOD_PREFIX_INIT)
80
                && \ts\stringStartsWith($method, UsesPHPMetaDataInterface::METHOD_PREFIX_INIT)
81
            ) {
82
                $this->$method();
83
            }
84
        }
85
    }
86
}
87