| Total Complexity | 4 |
| Total Lines | 25 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | final class SpecCodeFeederPart implements ArrayPartInterface |
||
| 14 | { |
||
| 15 | 4 | public function feed(string $key, array $data, ClassType $class, PhpNamespace $namespace): void |
|
| 16 | { |
||
| 17 | 4 | $class->addMethod($this->getMethodName($key)) |
|
| 18 | 4 | ->setVisibility(ClassType::VISIBILITY_PRIVATE) |
|
| 19 | 4 | ->setReturnType('array') |
|
| 20 | 4 | ->setBody( |
|
| 21 | 4 | sprintf('return %s;', (new NsArrayPrinter($namespace))->printArray($data, 1, '')) |
|
| 22 | ); |
||
| 23 | 4 | } |
|
| 24 | |||
| 25 | 4 | private function getMethodName(string $key): string |
|
| 26 | { |
||
| 27 | 4 | return 'get' . str_replace('\\', '', $key) . 'Spec'; |
|
| 28 | } |
||
| 29 | |||
| 30 | 4 | public function matches(string $key): bool |
|
| 31 | { |
||
| 32 | 4 | return true; |
|
| 33 | } |
||
| 34 | |||
| 35 | 4 | public function getCalleeCode(string $key, array $data, PhpNamespace $namespace): PhpLiteral |
|
| 38 | } |
||
| 39 | } |
||
| 40 |