| Total Complexity | 9 |
| Total Lines | 51 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | class EntityBuilder extends AbstractBuilder |
||
| 8 | { |
||
| 9 | 3 | public function __construct(array $data, array $config = []) |
|
| 10 | { |
||
| 11 | 3 | $name = $data['name']; |
|
| 12 | 3 | $properties = !empty($data['properties']) && \is_array($data['properties']) |
|
| 13 | 3 | ? $data['properties'] |
|
| 14 | 3 | : []; |
|
| 15 | |||
| 16 | 3 | $_properties = \array_keys($properties); |
|
| 17 | |||
| 18 | 3 | $getters = $this->getGetters($properties); |
|
| 19 | 3 | $setters = $this->getSetters($properties); |
|
| 20 | |||
| 21 | 3 | parent::__construct(\compact('name', '_properties', 'getters', 'setters'), $config); |
|
| 22 | 3 | } |
|
| 23 | |||
| 24 | 3 | public function getFileTemplate(): string |
|
| 27 | } |
||
| 28 | |||
| 29 | 3 | public function getPathTemplate(): string |
|
| 32 | } |
||
| 33 | |||
| 34 | 3 | private function getGetters(array $properties): array |
|
| 35 | { |
||
| 36 | 3 | $getters = []; |
|
| 37 | |||
| 38 | 3 | foreach ($properties as $name => $attributes) { |
|
| 39 | 3 | $getters[$name] = new GetterBuilder([ |
|
| 40 | 3 | $name => $attributes |
|
| 41 | ]); |
||
| 42 | } |
||
| 43 | |||
| 44 | 3 | return $getters; |
|
| 45 | } |
||
| 46 | |||
| 47 | 3 | private function getSetters(array $properties): array |
|
| 58 | } |
||
| 59 | } |
||
| 60 |