Conditions | 3 |
Paths | 3 |
Total Lines | 17 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
49 | public static function encode(array $data): string |
||
50 | { |
||
51 | $serializer = new Serializer(); |
||
52 | foreach ($data as $value) { |
||
53 | $format = $value['format'] ?? null; |
||
54 | $content = $value['value'] ?? null; |
||
55 | if (empty($format)) { |
||
56 | continue; |
||
57 | } |
||
58 | $bigEndian = $value['big_endian'] ?? false; |
||
59 | match ($format) { |
||
60 | Formats::LONG => $serializer->addLong($content ?? 0, $bigEndian), |
||
61 | Formats::LONG_LONG => $serializer->addLongLong($content ?? 0, $bigEndian), |
||
62 | Formats::STRING => $serializer->addString((string)$content) |
||
63 | }; |
||
64 | } |
||
65 | return (string)$serializer; |
||
66 | } |
||
68 | } |