Conditions | 4 |
Paths | 5 |
Total Lines | 17 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
28 | public static function binary($value, array $definition){ |
||
29 | list($keyType, $valueType) = $definition; |
||
30 | $binary = pack('N', count($value)); |
||
31 | foreach($value as $key => $val) { |
||
32 | $keyPacked = $key instanceof Base |
||
33 | ? $key->getBinary() |
||
34 | : Base::getBinaryByType($keyType, $key); |
||
35 | |||
36 | $valuePacked = $val instanceof Base |
||
37 | ? $val->getBinary() |
||
38 | : Base::getBinaryByType($valueType, $val); |
||
39 | |||
40 | $binary .= pack('N', strlen($keyPacked)) . $keyPacked; |
||
41 | $binary .= pack('N', strlen($valuePacked)) . $valuePacked; |
||
42 | } |
||
43 | return $binary; |
||
44 | } |
||
45 | |||
50 |