Rule
class Rule extends Definition implements Stringable (View source)
Constants
protected DEFAULT |
Rule definition array defaults. |
SCHEMA |
Rule definition schema/structure. NOTE: All words prefixed with the
|
Properties
protected array<string,null|string|array|callable> | $definition | Rule definition array. |
from Definition |
protected mixed | $input | Rule input value. |
|
protected string | $statement | Rule statement string. |
|
static protected Closure | $translator | Rule messages translator. |
Methods
Rule constructor.
Executes the rule when the object is invoked as a function.
Returns the current rule statement.
Sets the arguments of the rule (returns object), or gets it if parameter is false
or not specified.
Asserts that the rule definition is valid.
Asserts that the rule statement is valid.
Sets the callback of the rule (returns object), or gets it if parameter is false
or not specified.
Sets the comparison of the rule (returns object), or gets it if parameter is false
or not specified.
Creates an error message for the rule using the currently available variables or the passed ones.
Sets the description of the rule (returns object), or gets it if parameter is false
or not specified.
Sets the example of the rule (returns object), or gets it if parameter is false
or not specified.
Executes the rule against some input (the current one or the passed one).
Gets rule input.
Gets rule statement string.
Sets the message of the rule (returns object), or gets it if parameter is false
or not specified.
Sets the name of the rule (returns object), or gets it if parameter is false
or not specified.
Sets the parameters of the rule (returns object), or gets it if parameter is false
or not specified.
Sets rule statement string.
Sets the variables of the rule (returns object), or gets it if parameter is false
or not specified.
Details
__construct(array|null $definition = null, string|null $statement = null, mixed $input = null)
Rule constructor.
mixed
__invoke(mixed $input)
Executes the rule when the object is invoked as a function.
string
__toString()
Returns the current rule statement.
array|static
arguments(array|false $arguments = false)
Sets the arguments of the rule (returns object), or gets it if parameter is false
or not specified.
protected void
assertDefinitionIsValid(array $definition)
Asserts that the rule definition is valid.
protected void
assertStatementIsValid(string $statement)
Asserts that the rule statement is valid.
callable|static
callback(callable|false $callback = false)
Sets the callback of the rule (returns object), or gets it if parameter is false
or not specified.
array|static
comparison(array|false $comparison = false)
Sets the comparison of the rule (returns object), or gets it if parameter is false
or not specified.
string
createErrorMessage(string|null $message = null, array|null $variables = null)
Creates an error message for the rule using the currently available variables or the passed ones.
null|string|static
description(string|false $description = false)
Sets the description of the rule (returns object), or gets it if parameter is false
or not specified.
null|string|static
example(string|false $example = false)
Sets the example of the rule (returns object), or gets it if parameter is false
or not specified.
mixed
execute(mixed $input = null)
Executes the rule against some input (the current one or the passed one).
array
getArguments()
Gets the arguments of the rule.
callable
getCallback()
Gets the callback of the rule.
array
getComparison()
Gets the comparison of the rule.
array
getDefinition()
Gets rule definition array.
string|null
getDescription()
Gets the description of the rule.
string|null
getExample()
Gets the example of the rule.
mixed
getInput()
Gets rule input.
string
getMessage()
Gets the message of the rule.
string
getName()
Gets the name of the rule.
array
getParameters()
Gets the parameters of the rule.
string
getStatement()
Gets rule statement string.
array|null
getVariables()
Gets the variables of the rule.
string|static
message(string|false $message = false)
Sets the message of the rule (returns object), or gets it if parameter is false
or not specified.
string|static
name(string|false $name = false)
Sets the name of the rule (returns object), or gets it if parameter is false
or not specified.
array|static
parameters(array|false $parameters = false)
Sets the parameters of the rule (returns object), or gets it if parameter is false
or not specified.
Definition
setArguments(array $arguments)
Gets the arguments of the rule.
Definition
setCallback(callable $callback)
Sets the callback of the rule.
Definition
setComparison(array $comparison)
Sets the comparison of the rule.
Definition
setDefinition(array $definition)
Sets rule definition array.
Definition
setDescription(string $description)
Sets the description of the rule.
Definition
setExample(string $example)
Sets the example of the rule.
Rule
setInput(mixed $input)
Sets rule input.
Definition
setMessage(string $message)
Sets the message of the rule.
static void
setMessageTranslator(Closure $translator)
Sets rule messages global translator.
Definition
setName(string $name)
Sets the name of the rule.
Definition
setParameters(array $parameters)
Sets the parameters of the rule.
Rule
setStatement(string $statement)
Sets rule statement string.
Definition
setVariables(array|null $variables)
Sets the variables of the rule.
null|array|static
variables(null|array|false $variables = false)
Sets the variables of the rule (returns object), or gets it if parameter is false
or not specified.