Code Duplication    Length = 12-13 lines in 6 locations

src/Reader/IntegerReader.php 3 locations

@@ 74-86 (lines=13) @@
71
     *
72
     * @return int
73
     */
74
    public function readSignedInteger16()
75
    {
76
        $data = $this->read(2);
77
78
        if ($this->getByteOrder() !== ByteOrder::MACHINE_ENDIAN
79
            && $this->getByteOrder() !== $this->getMachineByteOrder()
80
        ) {
81
            $data = strrev($data);
82
        }
83
84
        list(, $value) = unpack('s', $data);
85
        return $value;
86
    }
87
88
    /**
89
     * Read unsigned 24-bit integer (short) data from the stream
@@ 153-165 (lines=13) @@
150
     *
151
     * @return int
152
     */
153
    public function readSignedInteger32()
154
    {
155
        $data = $this->read(4);
156
157
        if ($this->getByteOrder() !== ByteOrder::MACHINE_ENDIAN
158
            && $this->getByteOrder() !== $this->getMachineByteOrder()
159
        ) {
160
            $data = strrev($data);
161
        }
162
163
        list(, $value) = unpack('l', $data);
164
        return $value;
165
    }
166
167
    /**
168
     * Read unsigned 64-bit integer (long long) data from the stream
@@ 194-206 (lines=13) @@
191
     *
192
     * @return int
193
     */
194
    public function readSignedInteger64()
195
    {
196
        $data = $this->read(8);
197
198
        if ($this->getByteOrder() !== ByteOrder::MACHINE_ENDIAN
199
            && $this->getByteOrder() !== $this->getMachineByteOrder()
200
        ) {
201
            $data = strrev($data);
202
        }
203
204
        list(, $value) = unpack('q', $data);
205
        return $value;
206
    }
207
}
208

src/Writer/IntegerWriter.php 3 locations

@@ 79-90 (lines=12) @@
76
     *
77
     * @return int
78
     */
79
    public function writeSignedInteger16($value)
80
    {
81
        $data = pack('s', $value);
82
83
        if ($this->getByteOrder() !== ByteOrder::MACHINE_ENDIAN
84
            && $this->getByteOrder() !== $this->getMachineByteOrder()
85
        ) {
86
            $data = strrev($data);
87
        }
88
89
        return $this->write($data);
90
    }
91
92
    /**
93
     * Write unsigned 24-bit integer (short) data to the stream
@@ 161-172 (lines=12) @@
158
     *
159
     * @return int
160
     */
161
    public function writeSignedInteger32($value)
162
    {
163
        $data = pack('l', $value);
164
165
        if ($this->getByteOrder() !== ByteOrder::MACHINE_ENDIAN
166
            && $this->getByteOrder() !== $this->getMachineByteOrder()
167
        ) {
168
            $data = strrev($data);
169
        }
170
171
        return $this->write($data);
172
    }
173
174
    /**
175
     * Write unsigned 64-bit integer (long long) data to the stream
@@ 204-215 (lines=12) @@
201
     *
202
     * @return int
203
     */
204
    public function writeSignedInteger64($value)
205
    {
206
        $data = pack('q', $value);
207
208
        if ($this->getByteOrder() !== ByteOrder::MACHINE_ENDIAN
209
            && $this->getByteOrder() !== $this->getMachineByteOrder()
210
        ) {
211
            $data = strrev($data);
212
        }
213
214
        return $this->write($data);
215
    }
216
}
217