| Total Complexity | 7 |
| Total Lines | 36 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 10 | class JsonExporter |
||
| 11 | { |
||
| 12 | private JsonExportable $exportable; |
||
| 13 | |||
| 14 | 3 | public function __construct(JsonExportable $exportable) |
|
| 15 | { |
||
| 16 | 3 | $this->exportable = $exportable; |
|
| 17 | 3 | } |
|
| 18 | |||
| 19 | 2 | public static function exportToJson(JsonExportable $exportable, $options = 0): string |
|
| 22 | } |
||
| 23 | |||
| 24 | 3 | public static function exportToCollection(JsonExportable $exportable): Collection |
|
| 29 | } |
||
| 30 | |||
| 31 | 3 | public function exportAttributes(): Collection |
|
| 32 | { |
||
| 33 | 3 | return collect($this->exportable->getJsonExportableAttributes()) |
|
| 34 | 3 | ->mapWithKeys(fn($attribute) => [$attribute => $this->exportable->$attribute]); |
|
| 35 | } |
||
| 36 | |||
| 37 | 2 | public function exportRelations(): Collection |
|
| 46 | 2 | }); |
|
| 47 | } |
||
| 49 |