Code Duplication    Length = 17-19 lines in 3 locations

src/AbstractEnumSet.php 1 location

@@ 332-350 (lines=19) @@
329
     * Get ordinal numbers of the defined enumerators as array
330
     * @return int[]
331
     */
332
    public function getOrdinals()
333
    {
334
        $ordinals = array();
335
        $byteLen  = strlen($this->bitset);
336
337
        for ($bytePos = 0; $bytePos < $byteLen; ++$bytePos) {
338
            if ($this->bitset[$bytePos] === "\0") {
339
                continue; // fast skip null byte
340
            }
341
342
            for ($bitPos = 0; $bitPos < 8; ++$bitPos) {
343
                if ((ord($this->bitset[$bytePos]) & (1 << $bitPos)) !== 0) {
344
                    $ordinals[] = $bytePos * 8 + $bitPos;
345
                }
346
            }
347
        }
348
349
        return $ordinals;
350
    }
351
352
    /**
353
     * Get values of the defined enumerators as array

src/BinaryEnumSet.php 1 location

@@ 314-332 (lines=19) @@
311
     * Get ordinal numbers of the defined enumerators as array
312
     * @return int[]
313
     */
314
    public function getOrdinals()
315
    {
316
        $ordinals = array();
317
        $byteLen  = strlen($this->bitset);
318
319
        for ($bytePos = 0; $bytePos < $byteLen; ++$bytePos) {
320
            if ($this->bitset[$bytePos] === "\0") {
321
                continue; // fast skip null byte
322
            }
323
324
            for ($bitPos = 0; $bitPos < 8; ++$bitPos) {
325
                if ((ord($this->bitset[$bytePos]) & (1 << $bitPos)) !== 0) {
326
                    $ordinals[] = $bytePos * 8 + $bitPos;
327
                }
328
            }
329
        }
330
331
        return $ordinals;
332
    }
333
334
    /**
335
     * Get values of the defined enumerators as array

src/EnumSet.php 1 location

@@ 459-475 (lines=17) @@
456
     * @see getOrdinals
457
     * @see goGetOrdinalsInt
458
     */
459
    private function doGetOrdinalsBin()
460
    {
461
        $ordinals = array();
462
        $byteLen = strlen($this->bitset);
463
        for ($bytePos = 0; $bytePos < $byteLen; ++$bytePos) {
464
            if ($this->bitset[$bytePos] === "\0") {
465
                continue; // fast skip null byte
466
            }
467
468
            for ($bitPos = 0; $bitPos < 8; ++$bitPos) {
469
                if ((ord($this->bitset[$bytePos]) & (1 << $bitPos)) !== 0) {
470
                    $ordinals[] = $bytePos * 8 + $bitPos;
471
                }
472
            }
473
        }
474
        return $ordinals;
475
    }
476
477
    /**
478
     * Get ordinal numbers of the defined enumerators as array.