Code Duplication    Length = 24-24 lines in 2 locations

src/Rule/AbstractOperationRule.php 2 locations

@@ 508-531 (lines=24) @@
505
     *
506
     * @return array The 3 dimensions array of operands: field > operator > i
507
     */
508
    public function groupOperandsByFieldAndOperator()
509
    {
510
        $operandsByFields = [];
511
        foreach ($this->operands as $operand) {
512
513
            // Operation rules have no field but we need to keep them anyway
514
            $field = method_exists($operand, 'getField') ? $operand->getField() : '';
515
516
            // For FilteredValue and FilteredKey
517
            $field = (string) $field;
518
519
            if ( ! isset($operandsByFields[ $field ])) {
520
                $operandsByFields[ $field ] = [];
521
            }
522
523
            if ( ! isset($operandsByFields[ $field ][ $operand::operator ])) {
524
                $operandsByFields[ $field ][ $operand::operator ] = [];
525
            }
526
527
            $operandsByFields[ $field ][ $operand::operator ][] = $operand;
528
        }
529
530
        return $operandsByFields;
531
    }
532
533
    /**
534
     * Indexes operands by their fields and operators. This sorting is
@@ 539-562 (lines=24) @@
536
     *
537
     * @return array The 3 dimensions array of operands: field > operator > i
538
     */
539
    protected static function groupOperandsByFieldAndOperator_static($operands)
540
    {
541
        $operandsByFields = [];
542
        foreach ($operands as $operand) {
543
544
            // Operation rules have no field but we need to keep them anyway
545
            $field = method_exists($operand, 'getField') ? $operand->getField() : '';
546
547
            // For FilteredValue and FilteredKey
548
            $field = (string) $field;
549
550
            if ( ! isset($operandsByFields[ $field ])) {
551
                $operandsByFields[ $field ] = [];
552
            }
553
554
            if ( ! isset($operandsByFields[ $field ][ $operand::operator ])) {
555
                $operandsByFields[ $field ][ $operand::operator ] = [];
556
            }
557
558
            $operandsByFields[ $field ][ $operand::operator ][] = $operand;
559
        }
560
561
        return $operandsByFields;
562
    }
563
564
    /**
565
     * Clones the rule and its operands.