| Total Complexity | 12 |
| Total Lines | 58 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 4 | trait TraitEntity |
||
| 5 | { |
||
| 6 | |||
| 7 | public function jsonSerialize(): mixed |
||
| 8 | { |
||
| 9 | $entity = clone $this; |
||
| 10 | |||
| 11 | if (method_exists($entity, 'beforeSerialize')) { |
||
| 12 | $entity->beforeSerialize(); |
||
| 13 | } |
||
| 14 | |||
| 15 | return $entity->toArray(); |
||
| 16 | } |
||
| 17 | |||
| 18 | /** |
||
| 19 | * |
||
| 20 | * @return array |
||
| 21 | */ |
||
| 22 | public function toArray() |
||
| 23 | { |
||
| 24 | $vars = get_object_vars($this); |
||
| 25 | |||
| 26 | if ($this->hiddenNullValues()) { |
||
| 27 | return array_filter($vars, function ($value) { |
||
| 28 | return null !== $value; |
||
| 29 | }); |
||
| 30 | } |
||
| 31 | |||
| 32 | return $vars; |
||
| 33 | } |
||
| 34 | |||
| 35 | /** |
||
| 36 | * |
||
| 37 | * @return false|string |
||
| 38 | */ |
||
| 39 | public function toJSON($hiddenNull = true) |
||
| 46 | } |
||
| 47 | |||
| 48 | public function populateByArray(array $body, array $blockFields = []) |
||
| 57 | } |
||
| 58 | |||
| 59 | private function hiddenNullValues(): bool |
||
| 62 | } |
||
| 63 | } |