Factory
extends Factory
in package
Prophecy comparator factory.
Tags
Table of Contents
- $customComparators : array<string|int, Comparator>
- $defaultComparators : 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.
- 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
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 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
Return values
mixed —reset()
Unregisters all non-default comparators.
public
reset() : mixed
Return values
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
Return values
mixed —registerDefaultComparator()
private
registerDefaultComparator(Comparator $comparator) : void
Parameters
- $comparator : Comparator
Return values
void —registerDefaultComparators()
private
registerDefaultComparators() : void