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 ( 394cf2...003ff0 )
by Constantin
02:34
created

SubclassComparator   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 0
dl 0
loc 22
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A isASubClass() 0 4 1
A isASubClassOrSameClass() 0 4 2
A isASubClassButNoSameClass() 0 4 2
A getObjectClass() 0 4 2
1
<?php
2
3
4
namespace Gica\CodeAnalysis\Shared\ClassComparison;
5
6
7
class SubclassComparator
8
{
9 5
    public function isASubClass($object, string $parentClass)
10
    {
11 5
        return is_subclass_of($object, $parentClass);
0 ignored issues
show
Bug introduced by
Due to PHP Bug #53727, is_subclass_of might return inconsistent results on some PHP versions if $parentClass can be an interface. If so, you could instead use ReflectionClass::implementsInterface.
Loading history...
12
    }
13
14 3
    public function isASubClassOrSameClass($object, string $parentClass)
15
    {
16 3
        return $this->isASubClass($object, $parentClass) || $this->getObjectClass($object) === $parentClass;
17
    }
18
19 1
    public function isASubClassButNoSameClass($object, string $parentClass)
20
    {
21 1
        return $this->isASubClass($object, $parentClass) && $this->getObjectClass($object) !== $parentClass;
22
    }
23
24 4
    private function getObjectClass($object): string
25
    {
26 4
        return is_string($object) ? $object : get_class($object);
27
    }
28
}