Code Duplication    Length = 7-11 lines in 5 locations

src/Rule/AndRule.php 5 locations

@@ 680-686 (lines=7) @@
677
        if ( ! empty($operandsByOperator[ InRule::operator ])) {
678
            $inRule = $operandsByOperator[ InRule::operator ][0];
679
680
            if ( ! empty($operandsByOperator[ NotInRule::operator ])) {
681
                $notInRule = reset($operandsByOperator[ NotInRule::operator ]);
682
                $operandsByOperator[ InRule::operator ][0]->setPossibilities(
683
                    array_diff( $inRule->getPossibilities(), $notInRule->getPossibilities())
684
                );
685
                unset($operandsByOperator[ NotInRule::operator ]);
686
            }
687
688
            if ( ! empty($operandsByOperator[ BelowRule::operator ])) {
689
                $upper_limit = reset($operandsByOperator[ BelowRule::operator ])->getUpperLimit();
@@ 688-698 (lines=11) @@
685
                unset($operandsByOperator[ NotInRule::operator ]);
686
            }
687
688
            if ( ! empty($operandsByOperator[ BelowRule::operator ])) {
689
                $upper_limit = reset($operandsByOperator[ BelowRule::operator ])->getUpperLimit();
690
691
                $operandsByOperator[ InRule::operator ][0]->setPossibilities(
692
                    array_filter( $inRule->getPossibilities(), function ($possibility) use ($upper_limit) {
693
                        return $possibility < $upper_limit;
694
                    } )
695
                );
696
697
                unset($operandsByOperator[ BelowRule::operator ]);
698
            }
699
700
            if ( ! empty($operandsByOperator[ AboveRule::operator ])) {
701
                $lower_limit = reset($operandsByOperator[ AboveRule::operator ])->getLowerLimit();
@@ 700-710 (lines=11) @@
697
                unset($operandsByOperator[ BelowRule::operator ]);
698
            }
699
700
            if ( ! empty($operandsByOperator[ AboveRule::operator ])) {
701
                $lower_limit = reset($operandsByOperator[ AboveRule::operator ])->getLowerLimit();
702
703
                $operandsByOperator[ InRule::operator ][0]->setPossibilities(
704
                    array_filter( $inRule->getPossibilities(), function ($possibility) use ($lower_limit) {
705
                        return $possibility > $lower_limit;
706
                    } )
707
                );
708
709
                unset($operandsByOperator[ AboveRule::operator ]);
710
            }
711
        }
712
713
        // Comparison between NotInRules and > or <
@@ 717-725 (lines=9) @@
714
        if ( ! empty($operandsByOperator[ NotInRule::operator ])) {
715
            $notInRule = $operandsByOperator[ NotInRule::operator ][0];
716
717
            if ( ! empty($operandsByOperator[ BelowRule::operator ])) {
718
                $upper_limit = reset($operandsByOperator[ BelowRule::operator ])->getUpperLimit();
719
720
                $operandsByOperator[ NotInRule::operator ][0]->setPossibilities(
721
                    array_filter( $notInRule->getPossibilities(), function ($possibility) use ($upper_limit) {
722
                        return $possibility < $upper_limit;
723
                    } )
724
                );
725
            }
726
727
            if ( ! empty($operandsByOperator[ AboveRule::operator ])) {
728
                $lower_limit = reset($operandsByOperator[ AboveRule::operator ])->getLowerLimit();
@@ 727-735 (lines=9) @@
724
                );
725
            }
726
727
            if ( ! empty($operandsByOperator[ AboveRule::operator ])) {
728
                $lower_limit = reset($operandsByOperator[ AboveRule::operator ])->getLowerLimit();
729
730
                $operandsByOperator[ NotInRule::operator ][0]->setPossibilities(
731
                    array_filter( $notInRule->getPossibilities(), function ($possibility) use ($lower_limit) {
732
                        return $possibility > $lower_limit;
733
                    } )
734
                );
735
            }
736
        }
737
738
        // Comparison between <= and > or <