Skip to main content

GravityKit\GravityMigrate\Schema\LogicRule

One test against one answer: this field, this comparison, this value.

The comparisons are named in the canonical vocabulary rather than any platform's spelling. Gravity Forms writes isnot and doesnotcontain, and its own editor writes the symbols > and < while its evaluator also accepts the words; every platform has its own set. Translation happens at the edges, so an adapter that mistranslates fails against this closed list instead of inventing a comparison nothing evaluates.

Gravity Forms evaluates nine operators and returns false for everything else, so a rule carrying an operator it does not know never matches: a field set to show when an answer is empty simply never appears, with no error anywhere.

Since: %ver%

Source: src/Schema/LogicRule.php:25

Details

  • Kind: class
  • Namespace: GravityKit\GravityMigrate\Schema

Methods

MethodDescription
to_array()The rule as plain data.
from_array()Reads a rule back, or refuses it.
compare()A test against one field's answer.
get_field_id()The field whose answer is tested.
set_field_id()Points the rule at a different field.
get_operator()The comparison being made.
get_value()What the answer is compared against.
tests_emptiness()Whether this comparison tests emptiness, and so needs no value.

Method Reference

to_array()

public function to_array(): array

The rule as plain data.

Returns

  • array{field_id: — mixed, operator: string, value: string}

Since: %ver%

Source: src/Schema/LogicRule.php:79

from_array()

public static function from_array( $rule ): ?self

Reads a rule back, or refuses it.

Parameters

NameTypeDefaultDescription
$rulemixedCandidate rule.

Returns

  • self | null — Null for anything that cannot be rebuilt exactly, including an operator outside the vocabulary. A rule set that has lost a rule decides differently from the one somebody built, so a null is not a rule to skip.

Since: %ver%

Source: src/Schema/LogicRule.php:98

compare()

public static function compare( $field_id, string $operator, string $value='' ): ?self

A test against one field's answer.

Parameters

NameTypeDefaultDescription
$field_idint | stringField whose answer is tested.
$operatorstringOne of the OPERATORS.
$valuestring''Comparison value; ignored for the emptiness comparisons.

Returns

  • self | null — Null for an operator outside the vocabulary. A comparison no platform evaluates would be a rule that silently never matches.

Since: %ver%

Source: src/Schema/LogicRule.php:176

get_field_id()

public function get_field_id()

The field whose answer is tested.

Returns

  • int | string

Since: %ver%

Source: src/Schema/LogicRule.php:195

set_field_id()

public function set_field_id( $field_id ): self

Points the rule at a different field.

A rule's field id changes when a form is rebuilt somewhere else, since the target assigns its own ids.

Parameters

NameTypeDefaultDescription
$field_idint | stringField id.

Returns

  • self

Since: %ver%

Source: src/Schema/LogicRule.php:211

get_operator()

public function get_operator(): string

The comparison being made.

Returns

  • string

Since: %ver%

Source: src/Schema/LogicRule.php:224

get_value()

public function get_value(): string

What the answer is compared against.

Returns

  • string

Since: %ver%

Source: src/Schema/LogicRule.php:235

tests_emptiness()

public function tests_emptiness(): bool

Whether this comparison tests emptiness, and so needs no value.

Returns

  • bool

Since: %ver%

Source: src/Schema/LogicRule.php:246