]> BookStack Code Mirror - bookstack/blob - app/Exports/ZipExportModels/ZipExportModel.php
26b994c018ef7e37e3f8f1bc7e0edc22c6b794a0
[bookstack] / app / Exports / ZipExportModels / ZipExportModel.php
1 <?php
2
3 namespace BookStack\Exports\ZipExportModels;
4
5 use JsonSerializable;
6
7 abstract class ZipExportModel implements JsonSerializable
8 {
9     /**
10      * Handle the serialization to JSON.
11      * For these exports, we filter out optional (represented as nullable) fields
12      * just to clean things up and prevent confusion to avoid null states in the
13      * resulting export format itself.
14      */
15     public function jsonSerialize(): array
16     {
17         $publicProps = get_object_vars(...)->__invoke($this);
18         return array_filter($publicProps, fn ($value) => $value !== null);
19     }
20 }