| Conditions | 4 |
| Paths | 4 |
| Total Lines | 19 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 20 |
| Changes | 0 | ||
| 1 | <?php |
||
| 23 | public function createByModelAttributes($model, $map, array $parents = []) |
||
| 24 | { |
||
| 25 | $result = []; |
||
| 26 | |||
| 27 | foreach ($map as $attributeName => $definition) { |
||
| 28 | if (!is_array($definition)) { |
||
| 29 | $result[] = is_object($definition) ? $definition : $this->buildField($model, $attributeName, $definition, $parents); |
||
| 30 | } else { |
||
| 31 | $relationClass = $model->getRelation($attributeName); |
||
| 32 | $result = array_merge($result, $this->createByModelAttributes( |
||
| 33 | new $relationClass(), |
||
| 34 | $definition, |
||
| 35 | array_merge($parents, [$attributeName]) |
||
| 36 | )); |
||
| 37 | } |
||
| 38 | } |
||
| 39 | |||
| 40 | return $result; |
||
| 41 | } |
||
| 42 | |||
| 56 |