Code Duplication    Length = 15-16 lines in 6 locations

src/Reader/IntegerReader.php 3 locations

@@ 52-67 (lines=16) @@
49
     *
50
     * @return int
51
     */
52
    public function readUnsignedInteger16()
53
    {
54
        switch ($this->getByteOrder()) {
55
            case ByteOrder::BIG_ENDIAN:
56
                $format = 'n';
57
                break;
58
            case ByteOrder::LITTLE_ENDIAN:
59
                $format = 'v';
60
                break;
61
            default:
62
                $format = 'S';
63
        }
64
65
        list(, $value) = unpack($format, $this->read(2));
66
        return $value;
67
    }
68
69
    /**
70
     * Read signed 16-bit integer (short) data from the stream
@@ 131-146 (lines=16) @@
128
     *
129
     * @return int
130
     */
131
    public function readUnsignedInteger32()
132
    {
133
        switch ($this->getByteOrder()) {
134
            case ByteOrder::BIG_ENDIAN:
135
                $format = 'N';
136
                break;
137
            case ByteOrder::LITTLE_ENDIAN:
138
                $format = 'V';
139
                break;
140
            default:
141
                $format = 'L';
142
        }
143
144
        list(, $value) = unpack($format, $this->read(4));
145
        return $value;
146
    }
147
148
    /**
149
     * Read signed 32-bit integer (long) data from the stream
@@ 172-187 (lines=16) @@
169
     *
170
     * @return int
171
     */
172
    public function readUnsignedInteger64()
173
    {
174
        switch ($this->getByteOrder()) {
175
            case ByteOrder::BIG_ENDIAN:
176
                $format = 'J';
177
                break;
178
            case ByteOrder::LITTLE_ENDIAN:
179
                $format = 'P';
180
                break;
181
            default:
182
                $format = 'Q';
183
        }
184
185
        list(, $value) = unpack($format, $this->read(8));
186
        return $value;
187
    }
188
189
    /**
190
     * Read signed 64-bit integer (long long) data from the stream

src/Writer/IntegerWriter.php 3 locations

@@ 56-70 (lines=15) @@
53
     *
54
     * @return int
55
     */
56
    public function writeUnsignedInteger16($value)
57
    {
58
        switch ($this->getByteOrder()) {
59
            case ByteOrder::BIG_ENDIAN:
60
                $format = 'n';
61
                break;
62
            case ByteOrder::LITTLE_ENDIAN:
63
                $format = 'v';
64
                break;
65
            default:
66
                $format = 'S';
67
        }
68
69
        return $this->write(pack($format, $value));
70
    }
71
72
    /**
73
     * Write signed 16-bit integer (short) data to the stream
@@ 138-152 (lines=15) @@
135
     *
136
     * @return int
137
     */
138
    public function writeUnsignedInteger32($value)
139
    {
140
        switch ($this->getByteOrder()) {
141
            case ByteOrder::BIG_ENDIAN:
142
                $format = 'N';
143
                break;
144
            case ByteOrder::LITTLE_ENDIAN:
145
                $format = 'V';
146
                break;
147
            default:
148
                $format = 'L';
149
        }
150
151
        return $this->write(pack($format, $value));
152
    }
153
154
    /**
155
     * Write signed 32-bit integer (long) data to the stream
@@ 181-195 (lines=15) @@
178
     *
179
     * @return int
180
     */
181
    public function writeUnsignedInteger64($value)
182
    {
183
        switch ($this->getByteOrder()) {
184
            case ByteOrder::BIG_ENDIAN:
185
                $format = 'J';
186
                break;
187
            case ByteOrder::LITTLE_ENDIAN:
188
                $format = 'P';
189
                break;
190
            default:
191
                $format = 'Q';
192
        }
193
194
        return $this->write(pack($format, $value));
195
    }
196
197
    /**
198
     * Write signed 64-bit integer (long long) data to the stream