| Total Complexity | 8 |
| Total Lines | 85 |
| Duplicated Lines | 0 % |
| Coverage | 43.48% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 8 | class Info extends Record implements \ArrayAccess |
||
| 9 | { |
||
| 10 | const TYPE = 7; |
||
| 11 | const SUBTYPE = 0; |
||
| 12 | |||
| 13 | /** |
||
| 14 | * @var array |
||
| 15 | */ |
||
| 16 | protected $data = []; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * @var int Size of each piece of data in the data part, in bytes |
||
| 20 | */ |
||
| 21 | protected $dataSize = 1; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * @var int Number of pieces of data in the data part |
||
| 25 | */ |
||
| 26 | protected $dataCount = 0; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @param Buffer $buffer |
||
| 30 | */ |
||
| 31 | 2 | public function read(Buffer $buffer) |
|
| 32 | { |
||
| 33 | 2 | $this->dataSize = $buffer->readInt(); |
|
| 34 | 2 | $this->dataCount = $buffer->readInt(); |
|
| 35 | 2 | } |
|
| 36 | |||
| 37 | /** |
||
| 38 | * @param Buffer $buffer |
||
| 39 | */ |
||
| 40 | 2 | public function write(Buffer $buffer) |
|
| 41 | { |
||
| 42 | 2 | $buffer->writeInt(self::TYPE); |
|
| 43 | 2 | $buffer->writeInt(static::SUBTYPE); |
|
| 44 | 2 | $buffer->writeInt($this->dataSize); |
|
| 45 | 2 | $buffer->writeInt($this->dataCount); |
|
| 46 | 2 | } |
|
| 47 | |||
| 48 | /** |
||
| 49 | * @return array |
||
| 50 | */ |
||
| 51 | public function toArray() |
||
| 52 | { |
||
| 53 | return (array) $this->data; |
||
| 54 | } |
||
| 55 | |||
| 56 | /** |
||
| 57 | * @param mixed $offset |
||
| 58 | * @return bool |
||
| 59 | */ |
||
| 60 | public function offsetExists($offset) |
||
| 63 | } |
||
| 64 | |||
| 65 | /** |
||
| 66 | * @param mixed $offset |
||
| 67 | * @return mixed |
||
| 68 | */ |
||
| 69 | public function offsetGet($offset) |
||
| 70 | { |
||
| 71 | return $this->data[$offset]; |
||
| 72 | } |
||
| 73 | |||
| 74 | /** |
||
| 75 | * @param mixed $offset |
||
| 76 | * @param mixed $value |
||
| 77 | */ |
||
| 78 | public function offsetSet($offset, $value) |
||
| 79 | { |
||
| 80 | if (is_null($offset)) { |
||
| 81 | $this->data[] = $value; |
||
| 82 | } else { |
||
| 83 | $this->data[$offset] = $value; |
||
| 84 | } |
||
| 85 | } |
||
| 86 | |||
| 87 | /** |
||
| 88 | * @param mixed $offset |
||
| 89 | */ |
||
| 90 | public function offsetUnset($offset) |
||
| 93 | } |
||
| 94 | } |
||
| 95 |