| Conditions | 3 |
| Paths | 3 |
| Total Lines | 20 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 12 |
| Changes | 0 | ||
| 1 | <?php |
||
| 14 | public function createByModelAttributes($model, $map, $parentRelations = []) |
||
| 15 | { |
||
| 16 | $result = []; |
||
| 17 | |||
| 18 | foreach ($map as $attributeName => $definition) { |
||
| 19 | if (!is_array($definition)) { |
||
| 20 | $name = implode(array_merge($parentRelations, [$attributeName]), $this->getHierarchySeparator()); |
||
| 21 | $result[] = new Field($name, $definition, $model->getAttribute($attributeName)); |
||
| 22 | } else { |
||
| 23 | $relationClass = $model->getRelation($attributeName); |
||
| 24 | $result = array_merge($result, $this->createByModelAttributes( |
||
| 25 | new $relationClass, |
||
| 26 | $definition, |
||
| 27 | array_merge($parentRelations, [$attributeName]) |
||
| 28 | )); |
||
| 29 | } |
||
| 30 | } |
||
| 31 | |||
| 32 | return $result; |
||
| 33 | } |
||
| 34 | |||
| 40 |