Factory
in package
Factory for comparators which compare values for equality.
Table of Contents
Properties
- $customComparators : array<string|int, Comparator>
- $defaultComparators : array<string|int, Comparator>
- $instance : Factory
Methods
- __construct() : mixed
- Constructs a new factory.
- getComparatorFor() : Comparator
- Returns the correct comparator for comparing two values.
- getInstance() : Factory
- register() : mixed
- Registers a new comparator.
- reset() : mixed
- Unregisters all non-default comparators.
- unregister() : mixed
- Unregisters a comparator.
- registerDefaultComparator() : void
- registerDefaultComparators() : void
Properties
$customComparators
private
array<string|int, Comparator>
$customComparators
= []
$defaultComparators
private
array<string|int, Comparator>
$defaultComparators
= []
$instance
private
static Factory
$instance
Methods
__construct()
Constructs a new factory.
public
__construct() : mixed
getComparatorFor()
Returns the correct comparator for comparing two values.
public
getComparatorFor(mixed $expected, mixed $actual) : Comparator
Parameters
- $expected : mixed
-
The first value to compare
- $actual : mixed
-
The second value to compare
Return values
ComparatorgetInstance()
public
static getInstance() : Factory
Return values
Factoryregister()
Registers a new comparator.
public
register(Comparator $comparator) : mixed
This comparator will be returned by getComparatorFor() if its accept() method returns TRUE for the compared values. It has higher priority than the existing comparators, meaning that its accept() method will be invoked before those of the other comparators.
Parameters
- $comparator : Comparator
-
The comparator to be registered
reset()
Unregisters all non-default comparators.
public
reset() : mixed
unregister()
Unregisters a comparator.
public
unregister(Comparator $comparator) : mixed
This comparator will no longer be considered by getComparatorFor().
Parameters
- $comparator : Comparator
-
The comparator to be unregistered
registerDefaultComparator()
private
registerDefaultComparator(Comparator $comparator) : void
Parameters
- $comparator : Comparator
registerDefaultComparators()
private
registerDefaultComparators() : void