LogicalXor
final class LogicalXor extends BinaryOperator (View source)
Methods
Evaluates the constraint for parameter $other.
Evaluates the constraint for parameter $other. Returns true if the constraint is met, false otherwise.
Throws an exception for the given compared value and test description.
Return additional failure description where needed.
Returns a custom string representation of the constraint object when it appears in context of an $operator expression.
Returns the description of the failure when this constraint appears in context of an $operator expression.
Reduces the sub-expression starting at $this by skipping degenerate sub-expression and returns first descendant constraint that starts a non-reducible sub-expression.
Returns the name of this operator.
Returns this operator's precedence.
Returns true if the $constraint needs to be wrapped with braces.
No description
Details
final mixed
__invoke(mixed $actual)
No description
bool|null
evaluate(mixed $other, string $description = '', bool $returnResult = false)
Evaluates the constraint for parameter $other.
If $returnResult is set to false (the default), an exception is thrown in case of a failure. null is returned otherwise.
If $returnResult is true, the result of the evaluation is returned as a boolean value instead: true in case of success, false in case of a failure.
int
count()
Counts the number of constraint elements.
bool
matches(mixed $other)
Evaluates the constraint for parameter $other. Returns true if the constraint is met, false otherwise.
protected never
fail(mixed $other, string $description, ComparisonFailure|null $comparisonFailure = null)
Throws an exception for the given compared value and test description.
protected string
additionalFailureDescription(mixed $other)
Return additional failure description where needed.
The function can be overridden to provide additional failure information like a diff
protected string
failureDescription(mixed $other)
Returns the description of the failure.
The beginning of failure messages is "Failed asserting that" in most cases. This method should return the second part of that sentence.
To provide additional failure information additionalFailureDescription can be used.
protected string
toStringInContext(Operator $operator, mixed $role)
Returns a custom string representation of the constraint object when it appears in context of an $operator expression.
The purpose of this method is to provide meaningful descriptive string in context of operators such as LogicalNot. Native PHPUnit constraints are supported out of the box by LogicalNot, but externally developed ones had no way to provide correct strings in this context.
The method shall return empty string, when it does not handle customization by itself.
protected string
failureDescriptionInContext(Operator $operator, mixed $role, mixed $other)
Returns the description of the failure when this constraint appears in context of an $operator expression.
The purpose of this method is to provide meaningful failure description in context of operators such as LogicalNot. Native PHPUnit constraints are supported out of the box by LogicalNot, but externally developed ones had no way to provide correct messages in this context.
The method shall return empty string, when it does not handle customization by itself.
protected Constraint
reduce()
Reduces the sub-expression starting at $this by skipping degenerate sub-expression and returns first descendant constraint that starts a non-reducible sub-expression.
See Constraint::reduce() for more.
protected string
valueToTypeStringFragment(mixed $value)
No description
string
operator()
Returns the name of this operator.
int
precedence()
Returns this operator's precedence.
final int
arity()
Returns the number of operands (constraints).
protected Constraint
checkConstraint(mixed $constraint)
Validates $constraint argument.
final protected bool
constraintNeedsParentheses(Constraint $constraint)
Returns true if the $constraint needs to be wrapped with braces.
protected
__construct(mixed ...$constraints)
No description
string
toString()
Returns a string representation of the constraint.
final protected array
constraints()
No description
static LogicalXor
fromConstraints(mixed ...$constraints)
No description