Conditions | 7 |
Paths | 16 |
Total Lines | 24 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Tests | 17 |
CRAP Score | 7 |
Changes | 0 |
1 | <?php |
||
23 | 10 | public function feed(array $data, ClassType $class, PhpNamespace $namespace): void |
|
24 | { |
||
25 | 10 | $invoke = []; |
|
26 | |||
27 | 10 | foreach ($data as $key => $config) { |
|
28 | 10 | foreach ($this->parts as $part) { |
|
29 | 10 | if ($part->matches($key)) { |
|
30 | 10 | $invoke[$key] = $part->getCalleeCode($key, $config, $namespace); |
|
31 | 10 | break 1; |
|
32 | } |
||
33 | } |
||
34 | } |
||
35 | |||
36 | 10 | $invokeBody = 'return ' . (new NsArrayPrinter($namespace))->printArray($invoke, 1, '') . ";\n"; |
|
37 | 10 | $class->addMethod('__invoke') |
|
38 | 10 | ->setVisibility(ClassType::VISIBILITY_PUBLIC) |
|
39 | 10 | ->setReturnType('array') |
|
40 | 10 | ->setBody($invokeBody); |
|
41 | |||
42 | 10 | foreach ($data as $key => $config) { |
|
43 | 10 | foreach ($this->parts as $part) { |
|
44 | 10 | if ($part->matches($key)) { |
|
45 | 10 | $part->feed($key, $config, $class, $namespace); |
|
46 | 10 | break 1; |
|
47 | } |
||
52 |