AttributeRule implements CompilableMatcher
Read onlyYes
FinalYes
A single attribute-matching rule: a path into an attribute set, a comparison {@see MatchMode}, and an expected value. The leaf {@see Matcher}.
Interfaces
- CompilableMatcher
- A {@see Matcher} that can render itself as an inlined PHP boolean expression, letting {@see CompiledMatcher} compile the whole matcher tree to a cached PHP file instead of evaluating it through {@see Matcher::matches()}.
Methods
- __construct() : mixed
- compile() : string
- Render this rule as an inlined PHP boolean expression that reproduces {@see AttributeMatch} semantics without the per-call dispatch of the interpreted path. Expected values are scalar and emitted via {@see var_export()}, never concatenated raw.
- matches() : bool
Methods
__construct()
public
__construct(array<string|int, string>|string $path, MatchMode $mode, string|int|float|bool|DateTimeInterface $expected[, bool $caseSensitive = true ]) : mixed
Parameters
- $path : array<string|int, string>|string
-
attribute path: a top-level key, or segments descending into nested arrays
- $mode : MatchMode
- $expected : string|int|float|bool|DateTimeInterface
- $caseSensitive : bool = true
-
applies to the substring modes only (MatchMode::STARTS_WITH, MatchMode::ENDS_WITH, MatchMode::CONTAINS)
compile()
Render this rule as an inlined PHP boolean expression that reproduces {@see AttributeMatch} semantics without the per-call dispatch of the interpreted path. Expected values are scalar and emitted via {@see var_export()}, never concatenated raw.
public
compile(Compilation $compilation) : string
The generated code is kept in lock-step with the interpreted path by the compilation parity test; both must agree for every mode and value shape.
Parameters
- $compilation : Compilation
Tags
Return values
stringmatches()
public
matches(Attributes $attributes) : bool
Parameters
- $attributes : Attributes