Matches
extends Constraint
in package
Uses
ConstraintTrait
Constraint that checks if one value matches another.
The expected value is passed in the constructor. An EntityMap may be supplied for resolving operators (e.g. $$matchesEntity). Behavior for allowing extra keys in root documents and processing operators is also configurable.
Table of Contents
- $allowExtraRootKeys : bool
- $allowOperators : bool
- $entityMap : EntityMap
- $lastFailure : ComparisonFailure|null
- $value : mixed
- __construct() : mixed
- assertEquals() : void
- assertMatches() : void
- assertMatchesArray() : void
- assertMatchesDocument() : void
- assertMatchesOperator() : void
- doAdditionalFailureDescription() : mixed
- doEvaluate() : mixed
- doFailureDescription() : mixed
- doMatches() : mixed
- doToString() : mixed
- failAt() : void
- getOperatorName() : string
- isArrayEmptyOrIndexed() : bool
- isNumeric() : mixed
- isOperator() : bool
- prepare() : mixed
- Prepare a value for comparison.
Properties
$allowExtraRootKeys
private
bool
$allowExtraRootKeys
$allowOperators
private
bool
$allowOperators
$entityMap
private
EntityMap
$entityMap
$lastFailure
private
ComparisonFailure|null
$lastFailure
$value
private
mixed
$value
Methods
__construct()
public
__construct(mixed $value[, EntityMap|null $entityMap = null ][, mixed $allowExtraRootKeys = true ][, mixed $allowOperators = true ]) : mixed
Parameters
- $value : mixed
- $entityMap : EntityMap|null = null
- $allowExtraRootKeys : mixed = true
- $allowOperators : mixed = true
Return values
mixed —assertEquals()
private
assertEquals(mixed $expected, mixed $actual, string $keyPath) : void
Parameters
- $expected : mixed
- $actual : mixed
- $keyPath : string
Return values
void —assertMatches()
private
assertMatches(mixed $expected, mixed $actual[, string $keyPath = '' ]) : void
Parameters
- $expected : mixed
- $actual : mixed
- $keyPath : string = ''
Return values
void —assertMatchesArray()
private
assertMatchesArray(BSONArray $expected, mixed $actual, string $keyPath) : void
Parameters
- $expected : BSONArray
- $actual : mixed
- $keyPath : string
Return values
void —assertMatchesDocument()
private
assertMatchesDocument(BSONDocument $expected, mixed $actual, string $keyPath) : void
Parameters
- $expected : BSONDocument
- $actual : mixed
- $keyPath : string
Return values
void —assertMatchesOperator()
private
assertMatchesOperator(BSONDocument $operator, mixed $actual, string $keyPath) : void
Parameters
- $operator : BSONDocument
- $actual : mixed
- $keyPath : string
Return values
void —doAdditionalFailureDescription()
private
doAdditionalFailureDescription(mixed $other) : mixed
Parameters
- $other : mixed
Tags
Return values
mixed —doEvaluate()
private
doEvaluate(mixed $other[, mixed $description = '' ][, mixed $returnResult = false ]) : mixed
Parameters
- $other : mixed
- $description : mixed = ''
- $returnResult : mixed = false
Return values
mixed —doFailureDescription()
private
doFailureDescription(mixed $other) : mixed
Parameters
- $other : mixed
Tags
Return values
mixed —doMatches()
private
doMatches(mixed $other) : mixed
Parameters
- $other : mixed
Tags
Return values
mixed —doToString()
private
doToString() : mixed
Tags
Return values
mixed —failAt()
private
static failAt(string $message, string $keyPath) : void
Parameters
- $message : string
- $keyPath : string
Return values
void —getOperatorName()
private
static getOperatorName(BSONDocument $document) : string
Parameters
- $document : BSONDocument
Return values
string —isArrayEmptyOrIndexed()
private
static isArrayEmptyOrIndexed(array<string|int, mixed> $a) : bool
Parameters
- $a : array<string|int, mixed>
Return values
bool —isNumeric()
private
static isNumeric(mixed $value) : mixed
Parameters
- $value : mixed
Return values
mixed —isOperator()
private
static isOperator(BSONDocument $document) : bool
Parameters
- $document : BSONDocument
Return values
bool —prepare()
Prepare a value for comparison.
private
static prepare(mixed $bson) : mixed
If the value is an array or object, it will be converted to a BSONArray or BSONDocument. If $value is an array and $isRoot is true, it will be converted to a BSONDocument; otherwise, it will be converted to a BSONArray or BSONDocument based on its keys. Each value within an array or document will then be prepared recursively.
Parameters
- $bson : mixed