| Total Complexity | 8 |
| Total Lines | 85 |
| Duplicated Lines | 0 % |
| Coverage | 91.3% |
| 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 | 7 | public function read(Buffer $buffer) |
|
| 32 | { |
||
| 33 | 7 | $this->dataSize = $buffer->readInt(); |
|
| 34 | 7 | $this->dataCount = $buffer->readInt(); |
|
| 35 | 7 | } |
|
| 36 | |||
| 37 | /** |
||
| 38 | * @param Buffer $buffer |
||
| 39 | */ |
||
| 40 | 7 | public function write(Buffer $buffer) |
|
| 41 | { |
||
| 42 | 7 | $buffer->writeInt(self::TYPE); |
|
| 43 | 7 | $buffer->writeInt(static::SUBTYPE); |
|
| 44 | 7 | $buffer->writeInt($this->dataSize); |
|
| 45 | 7 | $buffer->writeInt($this->dataCount); |
|
| 46 | 7 | } |
|
| 47 | |||
| 48 | /** |
||
| 49 | * @return array |
||
| 50 | */ |
||
| 51 | 1 | public function toArray() |
|
| 52 | { |
||
| 53 | 1 | return (array) $this->data; |
|
| 54 | } |
||
| 55 | |||
| 56 | /** |
||
| 57 | * @param mixed $offset |
||
| 58 | * @return bool |
||
| 59 | */ |
||
| 60 | 4 | public function offsetExists($offset) |
|
| 61 | { |
||
| 62 | 4 | return isset($this->data[$offset]); |
|
| 63 | } |
||
| 64 | |||
| 65 | /** |
||
| 66 | * @param mixed $offset |
||
| 67 | * @return mixed |
||
| 68 | */ |
||
| 69 | 1 | public function offsetGet($offset) |
|
| 70 | { |
||
| 71 | 1 | return $this->data[$offset]; |
|
| 72 | } |
||
| 73 | |||
| 74 | /** |
||
| 75 | * @param mixed $offset |
||
| 76 | * @param mixed $value |
||
| 77 | */ |
||
| 78 | 5 | public function offsetSet($offset, $value) |
|
| 84 | } |
||
| 85 | 5 | } |
|
| 86 | |||
| 87 | /** |
||
| 88 | * @param mixed $offset |
||
| 89 | */ |
||
| 90 | public function offsetUnset($offset) |
||
| 93 | } |
||
| 94 | } |
||
| 95 |