ClassComparatorTrait   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 24
ccs 12
cts 12
cp 1
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A getMatchingClassNameIn() 0 16 2
1
<?php
2
namespace Yoanm\JsonRpcParamsSymfonyConstraintDoc\App\Helper;
3
4
/**
5
 * Trait ClassComparatorTrait
6
 */
7
trait ClassComparatorTrait
8
{
9
    /**
10
     * @param       $object
11
     * @param array $classList
12
     *
13
     * @return string|null
14
     */
15 232
    protected function getMatchingClassNameIn($object, array $classList) : ?string
16
    {
17 232
        $actualClassList = array_merge(
18 232
            [get_class($object)],
19 232
            class_implements($object),
20 232
            class_uses($object)
21 232
        );
22 232
        $parentClass = get_parent_class($object);
23 232
        while (false !== $parentClass) {
24 232
            $actualClassList[] = $parentClass;
25 232
            $parentClass = get_parent_class($parentClass);
26
        }
27
28 232
        $matchList = array_intersect($actualClassList, $classList);
29
30 232
        return array_pop($matchList);
31
    }
32
}
33