| Conditions | 6 |
| Paths | 5 |
| Total Lines | 15 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 6 |
| Changes | 0 | ||
| 1 | <?php |
||
| 7 | 6 | public function jsonSerialize(): array |
|
| 8 | { |
||
| 9 | 6 | $response = []; |
|
| 10 | 6 | $attributes = get_object_vars($this); |
|
| 11 | 6 | foreach ($attributes as $attribute => $value) { |
|
| 12 | 6 | if (is_array($value) && count($value)) { |
|
| 13 | 3 | $response[$attribute] = $value; |
|
| 14 | 6 | } elseif ($value instanceof \DateTime) { |
|
| 15 | 2 | $response[$attribute] = $value->format(DATE_ISO8601); |
|
| 16 | 6 | } elseif (!empty($value)) { |
|
| 17 | 6 | $response[$attribute] = $value; |
|
| 18 | } |
||
| 19 | } |
||
| 20 | |||
| 21 | 6 | return $response; |
|
| 22 | } |
||
| 26 |