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