1 | <?php |
||
2 | |||
3 | namespace Bdf\Serializer; |
||
4 | |||
5 | /** |
||
6 | * Serializer using binary representation |
||
7 | * Better performance and payload but not human readable and portable |
||
8 | * |
||
9 | * With igbinary : |
||
10 | * - Unserialize performance increased by ~20% |
||
11 | * - Serialized string is 10-15% smaller |
||
12 | * - No impact no serialize speed (can be slightly slower or faster) |
||
13 | * |
||
14 | * @uses igbinary |
||
15 | * @link https://github.com/igbinary/igbinary |
||
16 | */ |
||
17 | interface BinarySerializerInterface |
||
18 | { |
||
19 | /** |
||
20 | * Serialize data to binary |
||
21 | * |
||
22 | * @param mixed $data |
||
23 | * @param array $context |
||
24 | * |
||
25 | * @return string |
||
26 | */ |
||
27 | public function toBinary($data, array $context = []); |
||
28 | |||
29 | /** |
||
30 | * Restores objects from binary. |
||
31 | * |
||
32 | * @param string $raw |
||
33 | * @param class-string<T>|T $type The type of data. Can be the target object. |
||
0 ignored issues
–
show
Documentation
Bug
introduced
by
![]() |
|||
34 | * |
||
35 | * @return T|T[] this returns whatever the passed type is, typically an object or an array of objects |
||
36 | * |
||
37 | * @template T |
||
38 | */ |
||
39 | public function fromBinary(string $raw, $type); |
||
40 | } |
||
41 |