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.
Passed
Push — master ( d70c89...2d756e )
by Christian
01:55
created

AbstractListener::createDateTimeField()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 10
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 3
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * (c) Christian Gripp <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Core23\Doctrine\EventListener\ORM;
13
14
use Doctrine\Common\EventSubscriber;
15
use Doctrine\ORM\Mapping\ClassMetadata;
16
use ReflectionClass;
17
18
abstract class AbstractListener implements EventSubscriber
19
{
20
    /**
21
     * @param ReflectionClass $reflection
22
     * @param string          $class
23
     *
24
     * @return bool
25
     */
26
    final protected function containsTrait(ReflectionClass $reflection, string $class): bool
27
    {
28
        do {
29
            $traits = $reflection->getTraitNames();
30
31
            if (\in_array($class, $traits, true)) {
32
                return true;
33
            }
34
35
            foreach ($reflection->getTraits() as $reflTraits) {
36
                if ($this->containsTrait($reflTraits, $class)) {
37
                    return true;
38
                }
39
            }
40
        } while ($reflection = $reflection->getParentClass());
41
42
        return false;
43
    }
44
45
    /**
46
     * @param ClassMetadata $metadata
47
     * @param string        $field
48
     * @param bool          $nullable
49
     */
50
    final protected function createDateTimeField(ClassMetadata $metadata, string $field, bool $nullable): void
51
    {
52
        if ($metadata->hasField($field)) {
53
            return;
54
        }
55
56
        $metadata->mapField([
57
            'type'      => 'datetime',
58
            'fieldName' => $field,
59
            'nullable'  => $nullable,
60
        ]);
61
    }
62
}
63