Info   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 85
Duplicated Lines 0 %

Test Coverage

Coverage 43.48%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 20
c 1
b 0
f 0
dl 0
loc 85
ccs 10
cts 23
cp 0.4348
rs 10
wmc 8

7 Methods

Rating   Name   Duplication   Size   Complexity  
A offsetExists() 0 3 1
A offsetUnset() 0 3 1
A offsetGet() 0 3 1
A read() 0 4 1
A write() 0 6 1
A offsetSet() 0 6 2
A toArray() 0 3 1
1
<?php
2
3
namespace SPSS\Sav\Record;
4
5
use SPSS\Buffer;
6
use SPSS\Sav\Record;
7
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)
61
    {
62
        return isset($this->data[$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)
91
    {
92
        unset($this->data[$offset]);
93
    }
94
}
95