Passed
Push — master ( d8fa97...555fd2 )
by Yo
01:32
created

ClassComparatorTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 24
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0
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 79
    protected function getMatchingClassNameIn($object, array $classList) : ?string
16
    {
17 79
        $actualClassList = array_merge(
18 79
            [get_class($object)],
19 79
            class_implements($object),
20 79
            class_uses($object)
21
        );
22 79
        $parentClass = get_parent_class($object);
23 79
        while (false !== $parentClass) {
24 79
            $actualClassList[] = $parentClass;
25 79
            $parentClass = get_parent_class($parentClass);
26
        }
27
28 79
        $matchList = array_intersect($actualClassList, $classList);
29
30 79
        return array_pop($matchList);
31
    }
32
}
33