Code Duplication    Length = 13-13 lines in 2 locations

src/Address/IPv4.php 2 locations

@@ 185-197 (lines=13) @@
182
     * @example if $long == false: if the decimal representation is '0.7.8.255': '0.7.010.0377'
183
     * @example if $long == true: if the decimal representation is '0.7.8.255': '0000.0007.0010.0377'
184
     */
185
    public function toOctal($long = false)
186
    {
187
        $chunks = array();
188
        foreach ($this->getBytes() as $byte) {
189
            if ($long) {
190
                $chunks[] = sprintf('%04o', $byte);
191
            } else {
192
                $chunks[] = '0' . decoct($byte);
193
            }
194
        }
195
196
        return implode('.', $chunks);
197
    }
198
199
    /**
200
     * Get the hexadecimal representation of this IP address.
@@ 209-221 (lines=13) @@
206
     * @example if $long == false: if the decimal representation is '0.9.10.255': '0.9.0xa.0xff'
207
     * @example if $long == true: if the decimal representation is '0.9.10.255': '0x00.0x09.0x0a.0xff'
208
     */
209
    public function toHexadecimal($long = false)
210
    {
211
        $chunks = array();
212
        foreach ($this->getBytes() as $byte) {
213
            if ($long) {
214
                $chunks[] = sprintf('0x%02x', $byte);
215
            } else {
216
                $chunks[] = '0x' . dechex($byte);
217
            }
218
        }
219
220
        return implode('.', $chunks);
221
    }
222
223
    /**
224
     * {@inheritdoc}