class LogicalNot extends Constraint (View source)

Logical NOT.

Properties

protected $exporter from Constraint
protected Constraint $constraint

Methods

__construct(Constraint $constraint)

No description

mixed
evaluate(mixed $other, string $description = '', bool $returnResult = false)

Evaluates the constraint for parameter $other

bool
matches(mixed $other)

Evaluates the constraint for parameter $other. Returns true if the constraint is met, false otherwise.

int
count()

Counts the number of constraint elements.

fail(mixed $other, string $description, ComparisonFailure $comparisonFailure = null)

Throws an exception for the given compared value and test description

string
additionalFailureDescription(mixed $other)

Return additional failure description where needed

string
failureDescription(mixed $other)

Returns the description of the failure

static string
negate(string $string)

No description

string
toString()

Returns a string representation of the constraint.

Details

__construct(Constraint $constraint)

Parameters

Constraint $constraint

mixed 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.

Parameters

mixed $other Value or object to evaluate.
string $description Additional information about the test
bool $returnResult Whether to return a result or throw an exception

Return Value

mixed

Exceptions

ExpectationFailedException

protected bool matches(mixed $other)

Evaluates the constraint for parameter $other. Returns true if the constraint is met, false otherwise.

This method can be overridden to implement the evaluation algorithm.

Parameters

mixed $other Value or object to evaluate.

Return Value

bool

int count()

Counts the number of constraint elements.

Return Value

int

protected fail(mixed $other, string $description, ComparisonFailure $comparisonFailure = null)

Throws an exception for the given compared value and test description

Parameters

mixed $other Evaluated value or object.
string $description Additional information about the test
ComparisonFailure $comparisonFailure

Exceptions

ExpectationFailedException

protected string additionalFailureDescription(mixed $other)

Return additional failure description where needed

The function can be overridden to provide additional failure information like a diff

Parameters

mixed $other Evaluated value or object.

Return Value

string

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.

Parameters

mixed $other Evaluated value or object.

Return Value

string

static string negate(string $string)

Parameters

string $string

Return Value

string

string toString()

Returns a string representation of the constraint.

Return Value

string