Conditions | 3 |
Paths | 3 |
Total Lines | 19 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Tests | 6 |
CRAP Score | 3.1406 |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
27 | 9 | public static function getRender( |
|
28 | string $type, |
||
29 | Environment $environment, |
||
30 | string $render = Assets::RENDER_HTML |
||
31 | ): RenderInterface { |
||
32 | |||
33 | 9 | if(!array_key_exists($render, self::RENDERS)){ |
|
34 | 1 | throw new UnexpectedParameters( |
|
35 | 1 | sprintf('Invalid render group. Allowed only: %s', implode(', ', array_keys(self::RENDERS))) |
|
36 | ); |
||
37 | } |
||
38 | |||
39 | 8 | if (null === $renderClass = (self::RENDERS[$render][$type] ?? null)) { |
|
40 | throw new UnexpectedParameters( |
||
41 | sprintf('Invalid render. Allowed only: %s', implode(', ', array_keys(self::RENDERS[$render]))) |
||
42 | ); |
||
43 | } |
||
44 | |||
45 | 8 | return new $renderClass($environment); |
|
46 | } |
||
48 |