Conditions | 5 |
Paths | 5 |
Total Lines | 21 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 5.3906 |
Changes | 0 |
1 | <?php |
||
37 | 1 | public function make(string $code) |
|
38 | { |
||
39 | 1 | if (! empty($this->resolved[$code])) { |
|
40 | return $this->resolved[$code]; |
||
41 | } |
||
42 | |||
43 | 1 | if (empty($this->config)) { |
|
44 | throw new ConfigurationException('Фабрика не инициализирована'); |
||
45 | } |
||
46 | |||
47 | 1 | if (is_callable($this->config[$code])) { |
|
48 | $resolved = $this->config[$code](); |
||
49 | 1 | } elseif (is_string($code)) { |
|
|
|||
50 | 1 | $resolved = $this->getResolvedFromString($code); |
|
51 | } |
||
52 | |||
53 | 1 | Assert::isInstanceOf($resolved, $this->allowedType); |
|
54 | |||
55 | 1 | $this->resolved[$code] = $resolved; |
|
56 | |||
57 | 1 | return $this->resolved[$code]; |
|
58 | } |
||
87 |