| Conditions | 7 |
| Paths | 8 |
| Total Lines | 19 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 7.4822 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 34 | 3 | public function getGenerator(string $name): GeneratorInterface |
|
| 35 | { |
||
| 36 | 3 | if (!isset($this->generators[$name])) { |
|
| 37 | 1 | throw new GeneratorNotFoundException('Generator "' . $name . '" not found'); |
|
| 38 | } |
||
| 39 | 2 | $generator = $this->generators[$name]; |
|
| 40 | 2 | if (is_string($generator)) { |
|
| 41 | $generator = $this->container->get($generator); |
||
| 42 | 2 | } elseif ($generator instanceof GeneratorInterface) { |
|
| 43 | 1 | return $generator; |
|
| 44 | 1 | } elseif (is_object($generator) && method_exists($generator, '__invoke')) { |
|
| 45 | $generator = $generator($this->container); |
||
| 46 | } |
||
| 47 | 1 | if (!($generator instanceof GeneratorInterface)) { |
|
| 48 | 1 | throw new RuntimeException( |
|
| 49 | 1 | 'Generator should be GeneratorInterface instance. "' . get_class($generator) . '" given.' |
|
| 50 | ); |
||
| 51 | } |
||
| 52 | return $generator; |
||
| 53 | } |
||
| 55 |