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 ( f6d6d9...71fe6e )
by Christian
03:05
created

ClassUtils::containsTrait()   A

Complexity

Conditions 6
Paths 5

Size

Total Lines 21
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 21
rs 9.2222
c 0
b 0
f 0
cc 6
nc 5
nop 2
1
<?php
2
3
/*
4
 * (c) Christian Gripp <[email protected]>
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace Core23\Doctrine\Util;
11
12
use InvalidArgumentException;
13
use ReflectionClass;
14
15
final class ClassUtils
16
{
17
    /**
18
     * @param ReflectionClass $reflection
19
     * @param string          $class
20
     *
21
     * @return bool
22
     */
23
    public static function containsTrait(ReflectionClass $reflection, string $class): bool
24
    {
25
        if (!trait_exists($class)) {
26
            throw new InvalidArgumentException(sprintf('Class "%s" is not a valid trait', $class));
27
        }
28
29
        do {
30
            $traits = $reflection->getTraitNames();
31
32
            if (\in_array($class, $traits, true)) {
33
                return true;
34
            }
35
36
            foreach ($reflection->getTraits() as $reflTraits) {
37
                if (static::containsTrait($reflTraits, $class)) {
38
                    return true;
39
                }
40
            }
41
        } while ($reflection = $reflection->getParentClass());
42
43
        return false;
44
    }
45
}
46