| 1 | <?php |
||
| 20 | abstract class AbstractSerializer |
||
| 21 | { |
||
| 22 | /** |
||
| 23 | * @param Collection|Model[]|null $collection |
||
| 24 | * @return Collection |
||
| 25 | */ |
||
| 26 | public static function collection(?Collection $collection): Collection |
||
| 34 | |||
| 35 | /** |
||
| 36 | * @param object $model |
||
| 37 | * @return array |
||
| 38 | */ |
||
| 39 | public static function serialize($model): array |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @return \Closure |
||
| 50 | */ |
||
| 51 | public static function map(): \Closure |
||
| 57 | |||
| 58 | /** |
||
| 59 | * @param object $model |
||
| 60 | * @return array |
||
| 61 | */ |
||
| 62 | public function toArray($model): array |
||
| 66 | |||
| 67 | /** |
||
| 68 | * @param \DateTime|null $date |
||
| 69 | * @return string |
||
| 70 | */ |
||
| 71 | protected function formatDateTime(?\DateTime $date): string |
||
| 79 | } |
||
| 80 |
If a variable is not always an object, we recommend to add an additional type check to ensure your method call is safe: