Conditions | 6 |
Paths | 4 |
Total Lines | 21 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 6 |
Changes | 0 |
1 | <?php |
||
21 | public static function simplePayload(array $payload) : array |
||
22 | 6 | { |
|
23 | $payload = array_filter($payload, function ($val) { |
||
24 | 6 | // this will effectively remove empty arrays |
|
25 | 6 | if (is_array($val) && empty($val)) { |
|
26 | 6 | return false; |
|
27 | 4 | } |
|
28 | 4 | ||
29 | return !is_null($val); |
||
30 | 6 | }); |
|
31 | |||
32 | foreach ($payload as $key => $val) { |
||
33 | 6 | if (is_array($val)) { |
|
34 | $payload[$key] = static::simplePayload($val); |
||
35 | 6 | } elseif ($val instanceof PayloadInterface) { |
|
36 | 6 | $payload[$key] = static::simplePayload($val->getPayload()); |
|
37 | } |
||
38 | } |
||
39 | 3 | ||
40 | return $payload; |
||
41 | } |
||
42 | } |
||
43 |