Conditions | 6 |
Paths | 6 |
Total Lines | 25 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 6 |
Changes | 0 |
1 | <?php |
||
54 | 9 | public function resolve(Services $services) |
|
55 | { |
||
56 | 9 | if (!$this->reference instanceof Name) { |
|
57 | 2 | return $this->value; |
|
58 | } |
||
59 | |||
60 | try { |
||
61 | 7 | return $services->arguments()->get($this->reference); |
|
62 | 5 | } catch (ArgumentNotProvided $e) { |
|
63 | 3 | if ($e->argument()->hasDefault()) { |
|
64 | 1 | return $services->build($e->argument()->default()); |
|
65 | } |
||
66 | |||
67 | 2 | if ($e->argument()->optional()) { |
|
68 | 1 | return null; |
|
69 | } |
||
70 | |||
71 | 1 | throw $e; |
|
72 | 2 | } catch (ArgumentNotDefined $e) { |
|
73 | //pass |
||
74 | } |
||
75 | |||
76 | // todo: allow to resolve services from other dependencies |
||
77 | |||
78 | 2 | return $services->build($this->reference); |
|
79 | } |
||
81 |