Code Duplication    Length = 10-11 lines in 5 locations

PhpAmqpLib/Wire/AMQPWriter.php 5 locations

@@ 158-167 (lines=10) @@
155
     * @return $this
156
     * @throws \PhpAmqpLib\Exception\AMQPInvalidArgumentException
157
     */
158
    public function write_octet($n)
159
    {
160
        if ($n < 0 || $n > 255) {
161
            throw new AMQPInvalidArgumentException('Octet out of range: ' . $n);
162
        }
163
164
        $this->out .= chr($n);
165
166
        return $this;
167
    }
168
169
    public function write_signed_octet($n)
170
    {
@@ 169-178 (lines=10) @@
166
        return $this;
167
    }
168
169
    public function write_signed_octet($n)
170
    {
171
        if (($n < -128) || ($n > 127)) {
172
            throw new AMQPInvalidArgumentException('Signed octet out of range: ' . $n);
173
        }
174
175
        $this->out .= pack('c', $n);
176
177
        return $this;
178
    }
179
180
    /**
181
     * Write an integer as an unsigned 16-bit value
@@ 187-196 (lines=10) @@
184
     * @return $this
185
     * @throws \PhpAmqpLib\Exception\AMQPInvalidArgumentException
186
     */
187
    public function write_short($n)
188
    {
189
        if ($n < 0 || $n > 65535) {
190
            throw new AMQPInvalidArgumentException('Short out of range: ' . $n);
191
        }
192
193
        $this->out .= pack('n', $n);
194
195
        return $this;
196
    }
197
198
    public function write_signed_short($n)
199
    {
@@ 198-207 (lines=10) @@
195
        return $this;
196
    }
197
198
    public function write_signed_short($n)
199
    {
200
        if (($n < -32768) || ($n > 32767)) {
201
            throw new AMQPInvalidArgumentException('Signed short out of range: ' . $n);
202
        }
203
204
        $this->out .= $this->correctEndianness(pack('s', $n));
205
206
        return $this;
207
    }
208
209
    /**
210
     * Write an integer as an unsigned 32-bit value
@@ 234-244 (lines=11) @@
231
     * @param $n
232
     * @return $this
233
     */
234
    private function write_signed_long($n)
235
    {
236
        if (($n < -2147483648) || ($n > 2147483647)) {
237
            throw new AMQPInvalidArgumentException('Signed long out of range: ' . $n);
238
        }
239
240
        //on my 64bit debian this approach is slightly faster than splitIntoQuads()
241
        $this->out .= $this->correctEndianness(pack('l', $n));
242
243
        return $this;
244
    }
245
246
    /**
247
     * Write an integer as an unsigned 64-bit value