Code Duplication    Length = 23-23 lines in 2 locations

src/EnumSet.php 2 locations

@@ 433-455 (lines=23) @@
430
     * @param EnumSet ...$others Other EnumSet(s) of the same enumeration to produce the union
431
     * @return EnumSet
432
     */
433
    public function diff(...$others)
434
    {
435
        $clone = clone $this;
436
437
        if (isset($others[0])) {
438
            $bitset = $others[0]->bitset;
439
            foreach ($others as $other) {
440
                if (!$other instanceof self || $this->enumeration !== $other->enumeration) {
441
                    throw new InvalidArgumentException(sprintf(
442
                        'Others should of the same enumeration as this %s',
443
                        __CLASS__,
444
                        $this->enumeration
445
                    ));
446
                }
447
448
                $bitset |= $other->bitset;
449
            }
450
451
            $clone->bitset = $this->bitset & ~$bitset;
452
        }
453
454
        return $clone;
455
    }
456
457
    /**
458
     * Produce a new set with enumerators in either this and other but not in both (this ^ (other | other))
@@ 465-487 (lines=23) @@
462
     * @param EnumSet ...$others Other EnumSet(s) of the same enumeration to produce the union
463
     * @return EnumSet
464
     */
465
    public function symDiff(...$others)
466
    {
467
        $clone = clone $this;
468
469
        if (isset($others[0])) {
470
            $bitset = $others[0]->bitset;
471
            foreach ($others as $other) {
472
                if (!$other instanceof self || $this->enumeration !== $other->enumeration) {
473
                    throw new InvalidArgumentException(sprintf(
474
                        'Others should be an instance of %s of the same enumeration as this %s',
475
                        __CLASS__,
476
                        $this->enumeration
477
                    ));
478
                }
479
480
                $bitset |= $other->bitset;
481
            }
482
483
            $clone->bitset = $this->bitset ^ $bitset;
484
        }
485
486
        return $clone;
487
    }
488
489
    /**
490
     * Get ordinal numbers of the defined enumerators as array