Conditions | 7 |
Paths | 6 |
Total Lines | 18 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 7 |
Changes | 0 |
1 | <?php |
||
16 | 8 | public static function isClassSame(string $className, $validClass): bool |
|
17 | { |
||
18 | 8 | if (!class_exists($className) && !interface_exists($className)) { |
|
19 | 1 | throw new InvalidArgumentException(sprintf('The class/interface %s does not exist', $className)); |
|
20 | } |
||
21 | 7 | if (!\is_object($validClass)) { |
|
22 | 1 | throw new InvalidArgumentException(sprintf('The $validClass parameter %s is not an object', $validClass)); |
|
23 | } |
||
24 | 6 | if (\get_class($validClass) === $className) { |
|
25 | 3 | return true; |
|
26 | } |
||
27 | 5 | if (\in_array(LazyLoadingInterface::class, class_implements($validClass), true)) { |
|
28 | 2 | $reflection = new \ReflectionClass($validClass); |
|
29 | 2 | if ($reflection->isSubclassOf($className)) { |
|
30 | 2 | return true; |
|
31 | } |
||
32 | } |
||
33 | 4 | return ($validClass instanceof $className); |
|
34 | } |
||
53 |