Conditions | 5 |
Paths | 4 |
Total Lines | 23 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 13 |
CRAP Score | 5.0592 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
24 | 3 | private function extract(array $config, string $class): mixed |
|
25 | { |
||
26 | 3 | if (! isset($config['name'], $config['type'])) { |
|
27 | return $config; |
||
28 | } |
||
29 | |||
30 | 3 | if ($config['type'] instanceof Webonyx\Type) { |
|
31 | return $config; |
||
32 | } |
||
33 | |||
34 | 3 | $parameters = [ |
|
35 | 3 | 'name' => $config['name'], |
|
36 | 3 | 'type' => $config['type'], |
|
37 | 3 | 'typeMode' => $config['typeMode'] ?? 0, |
|
38 | 3 | 'description' => $config['description'] ?? null, |
|
39 | 3 | 'deprecationReason'=> $config['deprecationReason'] ?? null, |
|
40 | 3 | ]; |
|
41 | |||
42 | 3 | if (isset($config['defaultValue']) || array_key_exists('defaultValue', $config)) { |
|
43 | 1 | $parameters['defaultValue'] = $config['defaultValue']; |
|
44 | } |
||
45 | |||
46 | 3 | return new $class(...$parameters); |
|
47 | } |
||
49 |