Total Complexity | 5 |
Total Lines | 52 |
Duplicated Lines | 0 % |
Coverage | 70% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
24 | class MongoDBBinaryPacker implements PackerInterface |
||
25 | { |
||
26 | /** |
||
27 | * @var array |
||
28 | */ |
||
29 | protected $options; |
||
30 | |||
31 | /** |
||
32 | * SerializePacker constructor |
||
33 | * |
||
34 | * @param array $options Any options to be provided to unserialize() |
||
35 | */ |
||
36 | 61 | public function __construct(array $options = ['allowed_classes' => true]) |
|
39 | } |
||
40 | |||
41 | /** |
||
42 | * Get cache type (might be used as file extension) |
||
43 | * |
||
44 | * @return string |
||
45 | */ |
||
46 | public function getType() |
||
47 | { |
||
48 | return 'bson'; |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * Pack the value |
||
53 | * |
||
54 | * @param mixed $value |
||
55 | * @return string |
||
56 | */ |
||
57 | 61 | public function pack($value) |
|
58 | { |
||
59 | 61 | return new Binary(serialize($value), Binary::TYPE_GENERIC); |
|
60 | } |
||
61 | |||
62 | /** |
||
63 | * Unpack the value |
||
64 | * |
||
65 | * @param string $packed |
||
66 | * @return string |
||
67 | * @throws \UnexpectedValueException if he value can't be unpacked |
||
68 | */ |
||
69 | 37 | public function unpack($packed) |
|
76 | } |
||
77 | } |