Conditions | 3 |
Paths | 3 |
Total Lines | 16 |
Code Lines | 8 |
Lines | 16 |
Ratio | 100 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
63 | View Code Duplication | public function create($service) |
|
64 | { |
||
65 | if(!isset($this->serviceList[$service])) { |
||
66 | throw new NotFoundException('Service not found: ' . $service); |
||
67 | } |
||
68 | |||
69 | if (!class_exists($this->serviceList[$service]->class)) { |
||
70 | throw new ContainerException( |
||
71 | 'Class does not exists: ' . $this->serviceList[$service]->class |
||
72 | ); |
||
73 | } |
||
74 | |||
75 | $service = new \ReflectionClass($this->serviceList[$service]->class); |
||
76 | return $service->newInstance(); |
||
77 | |||
78 | } |
||
79 | } |
||
80 |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.