Reflection   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
dl 0
loc 39
ccs 13
cts 13
cp 1
rs 10
c 1
b 0
f 0
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getDependencies() 0 7 2
A __construct() 0 3 1
A isInstantiable() 0 7 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cekta\DI;
6
7
use ReflectionClass;
8
use ReflectionException;
9
10
class Reflection
11
{
12
    /**
13
     * @var Reflection\MethodService
14
     */
15
    private $reflectionMethod;
16
17 15
    public function __construct()
18
    {
19 15
        $this->reflectionMethod = new Reflection\MethodService();
20 15
    }
21
22
    /**
23
     * @param string $name
24
     * @return string[]
25
     * @internal
26
     */
27 12
    public function getDependencies(string $name): array
28
    {
29
        try {
30 12
            $class = new ReflectionClass($name);
31 9
            return $this->reflectionMethod->findDependencies($class->getConstructor());
32 3
        } catch (ReflectionException $exception) {
33 3
            return [];
34
        }
35
    }
36
37
    /**
38
     * @param string $name
39
     * @return bool
40
     * @internal
41
     */
42 3
    public function isInstantiable(string $name): bool
43
    {
44
        try {
45 3
            $class = new ReflectionClass($name);
46 3
            return $class->isInstantiable();
47 3
        } catch (ReflectionException $exception) {
48 3
            return false;
49
        }
50
    }
51
}
52