Code Duplication    Length = 13-13 lines in 4 locations

src/EnumSet.php 4 locations

@@ 377-389 (lines=13) @@
374
     * @param EnumSet $other EnumSet of the same enumeration to produce the union
375
     * @return EnumSet
376
     */
377
    public function union(EnumSet $other)
378
    {
379
        if ($this->enumeration !== $other->enumeration) {
380
            throw new InvalidArgumentException(\sprintf(
381
                'Other should be of the same enumeration as this %s',
382
                $this->enumeration
383
            ));
384
        }
385
386
        $clone = clone $this;
387
        $clone->bitset = $this->bitset | $other->bitset;
388
        return $clone;
389
    }
390
391
    /**
392
     * Produce a new set with enumerators common to both this and other (this & other)
@@ 397-409 (lines=13) @@
394
     * @param EnumSet $other EnumSet of the same enumeration to produce the intersect
395
     * @return EnumSet
396
     */
397
    public function intersect(EnumSet $other)
398
    {
399
        if ($this->enumeration !== $other->enumeration) {
400
            throw new InvalidArgumentException(\sprintf(
401
                'Other should be of the same enumeration as this %s',
402
                $this->enumeration
403
            ));
404
        }
405
406
        $clone = clone $this;
407
        $clone->bitset = $this->bitset & $other->bitset;
408
        return $clone;
409
    }
410
411
    /**
412
     * Produce a new set with enumerators in this but not in other (this - other)
@@ 417-429 (lines=13) @@
414
     * @param EnumSet $other EnumSet of the same enumeration to produce the diff
415
     * @return EnumSet
416
     */
417
    public function diff(EnumSet $other)
418
    {
419
        if ($this->enumeration !== $other->enumeration) {
420
            throw new InvalidArgumentException(\sprintf(
421
                'Other should be of the same enumeration as this %s',
422
                $this->enumeration
423
            ));
424
        }
425
426
        $clone = clone $this;
427
        $clone->bitset = $this->bitset & ~$other->bitset;
428
        return $clone;
429
    }
430
431
    /**
432
     * Produce a new set with enumerators in either this and other but not in both (this ^ other)
@@ 437-449 (lines=13) @@
434
     * @param EnumSet $other EnumSet of the same enumeration to produce the symmetric difference
435
     * @return EnumSet
436
     */
437
    public function symDiff(EnumSet $other)
438
    {
439
        if ($this->enumeration !== $other->enumeration) {
440
            throw new InvalidArgumentException(\sprintf(
441
                'Other should be of the same enumeration as this %s',
442
                $this->enumeration
443
            ));
444
        }
445
446
        $clone = clone $this;
447
        $clone->bitset = $this->bitset ^ $other->bitset;
448
        return $clone;
449
    }
450
451
    /**
452
     * Get ordinal numbers of the defined enumerators as array