| Conditions | 4 |
| Paths | 4 |
| Total Lines | 28 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 20 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 26 | public static function encode($line): array |
||
| 27 | { |
||
| 28 | if ($line instanceof Throwable) { |
||
| 29 | return [ |
||
| 30 | self::META_KEY => [ |
||
| 31 | self::TYPE_KEY => self::TYPE_THROWABLE, |
||
| 32 | ], |
||
| 33 | self::VALUE_KEY => throwable_encode($line), |
||
| 34 | ]; |
||
| 35 | } |
||
| 36 | |||
| 37 | $throwables = []; |
||
| 38 | $line = Hash::flatten($line); |
||
| 39 | foreach ($line as $key => $value) { |
||
| 40 | if (! ($value instanceof Throwable)) { |
||
| 41 | continue; |
||
| 42 | } |
||
| 43 | |||
| 44 | $throwables[] = $key; |
||
| 45 | $line[$key] = throwable_encode($value); |
||
| 46 | } |
||
| 47 | |||
| 48 | return [ |
||
| 49 | self::META_KEY => [ |
||
| 50 | self::TYPE_KEY => self::TYPE_ARRAY, |
||
| 51 | self::THROWABLES_KEY => $throwables, |
||
| 52 | ], |
||
| 53 | self::VALUE_KEY => $line, |
||
| 54 | ]; |
||
| 57 |