Code Duplication    Length = 7-11 lines in 5 locations

src/Rule/AndRule.php 5 locations

@@ 667-673 (lines=7) @@
664
        if ( ! empty($operandsByOperator[ InRule::operator ])) {
665
            $inRule = $operandsByOperator[ InRule::operator ][0];
666
667
            if ( ! empty($operandsByOperator[ NotInRule::operator ])) {
668
                $notInRule = reset($operandsByOperator[ NotInRule::operator ]);
669
                $operandsByOperator[ InRule::operator ][0]->setPossibilities(
670
                    array_diff( $inRule->getPossibilities(), $notInRule->getPossibilities())
671
                );
672
                unset($operandsByOperator[ NotInRule::operator ]);
673
            }
674
675
            if ( ! empty($operandsByOperator[ BelowRule::operator ])) {
676
                $upper_limit = reset($operandsByOperator[ BelowRule::operator ])->getMaximum();
@@ 675-685 (lines=11) @@
672
                unset($operandsByOperator[ NotInRule::operator ]);
673
            }
674
675
            if ( ! empty($operandsByOperator[ BelowRule::operator ])) {
676
                $upper_limit = reset($operandsByOperator[ BelowRule::operator ])->getMaximum();
677
678
                $operandsByOperator[ InRule::operator ][0]->setPossibilities(
679
                    array_filter( $inRule->getPossibilities(), function ($possibility) use ($upper_limit) {
680
                        return $possibility < $upper_limit;
681
                    } )
682
                );
683
684
                unset($operandsByOperator[ BelowRule::operator ]);
685
            }
686
687
            if ( ! empty($operandsByOperator[ AboveRule::operator ])) {
688
                $lower_limit = reset($operandsByOperator[ AboveRule::operator ])->getMinimum();
@@ 687-697 (lines=11) @@
684
                unset($operandsByOperator[ BelowRule::operator ]);
685
            }
686
687
            if ( ! empty($operandsByOperator[ AboveRule::operator ])) {
688
                $lower_limit = reset($operandsByOperator[ AboveRule::operator ])->getMinimum();
689
690
                $operandsByOperator[ InRule::operator ][0]->setPossibilities(
691
                    array_filter( $inRule->getPossibilities(), function ($possibility) use ($lower_limit) {
692
                        return $possibility > $lower_limit;
693
                    } )
694
                );
695
696
                unset($operandsByOperator[ AboveRule::operator ]);
697
            }
698
        }
699
700
        // Comparison between NotInRules and > or <
@@ 704-712 (lines=9) @@
701
        if ( ! empty($operandsByOperator[ NotInRule::operator ])) {
702
            $notInRule = $operandsByOperator[ NotInRule::operator ][0];
703
704
            if ( ! empty($operandsByOperator[ BelowRule::operator ])) {
705
                $upper_limit = reset($operandsByOperator[ BelowRule::operator ])->getUpperLimit();
706
707
                $operandsByOperator[ NotInRule::operator ][0]->setPossibilities(
708
                    array_filter( $notInRule->getPossibilities(), function ($possibility) use ($upper_limit) {
709
                        return $possibility < $upper_limit;
710
                    } )
711
                );
712
            }
713
714
            if ( ! empty($operandsByOperator[ AboveRule::operator ])) {
715
                $lower_limit = reset($operandsByOperator[ AboveRule::operator ])->getMinimum();
@@ 714-722 (lines=9) @@
711
                );
712
            }
713
714
            if ( ! empty($operandsByOperator[ AboveRule::operator ])) {
715
                $lower_limit = reset($operandsByOperator[ AboveRule::operator ])->getMinimum();
716
717
                $operandsByOperator[ NotInRule::operator ][0]->setPossibilities(
718
                    array_filter( $notInRule->getPossibilities(), function ($possibility) use ($lower_limit) {
719
                        return $possibility > $lower_limit;
720
                    } )
721
                );
722
            }
723
        }
724
725
        // Comparison between <= and > or <