Conditions | 3 |
Paths | 1 |
Total Lines | 9 |
Code Lines | 6 |
Lines | 0 |
Ratio | 0 % |
Tests | 7 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
37 | 2 | public function exportRelations(): Collection |
|
38 | { |
||
39 | 2 | return collect($this->exportable->getJsonExportableRelations()) |
|
40 | 2 | ->mapWithKeys(fn($relationName) => [$relationName => $this->exportable->$relationName()]) |
|
41 | 2 | ->filter(fn($relationObject) => $relationObject instanceof HasOneOrMany && $relationObject->getRelated() instanceof JsonExportable) |
|
42 | 2 | ->map(function (HasOneOrMany $relationObject) { |
|
43 | 2 | $export = $relationObject->get()->map(fn($object) => self::exportToCollection($object)); |
|
44 | |||
45 | 2 | return $relationObject instanceof HasOne ? $export->first() : $export; |
|
46 | 2 | }); |
|
49 |