Factory
in package
Factory for comparators which compare values for equality.
Table of Contents
- $comparators : array<string|int, Comparator>
- $instance : Factory
- __construct() : mixed
- Constructs a new factory.
- getComparatorFor() : Comparator
- Returns the correct comparator for comparing two values.
- getInstance() : Factory
- register() : mixed
- Registers a new comparator.
- unregister() : mixed
- Unregisters a comparator.
Properties
$comparators
private
array<string|int, Comparator>
$comparators
= array()
$instance
private
static Factory
$instance
Methods
__construct()
Constructs a new factory.
public
__construct() : mixed
Return values
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
Comparator —getInstance()
public
static getInstance() : Factory
Return values
Factory —register()
Registers a new comparator.
public
register(Comparator $comparator) : mixed
This comparator will be returned by getInstance() 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 tested before those of the other comparators.
Parameters
- $comparator : Comparator
-
The registered comparator
Return values
mixed —unregister()
Unregisters a comparator.
public
unregister(Comparator $comparator) : mixed
This comparator will no longer be returned by getInstance().
Parameters
- $comparator : Comparator
-
The unregistered comparator