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