-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathRestrictedComparable.php
More file actions
40 lines (37 loc) · 1.24 KB
/
RestrictedComparable.php
File metadata and controls
40 lines (37 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
namespace Icecave\Parity;
/**
* An object that can compare itself to a subset of other values.
*/
interface RestrictedComparable
{
/**
* Compare this object with another value, yielding a result according to
* the following table:
*
* +--------------------+---------------+
* | Condition | Result |
* +--------------------+---------------+
* | $this == $value | $result === 0 |
* | $this < $value | $result < 0 |
* | $this > $value | $result > 0 |
* +--------------------+---------------+
*
* @param mixed $value The value to compare.
*
* @return int The result of the comparison.
* @throws Exception\NotComparableException Indicates that the implementation does not know how to compare $this to $value.
*/
public function compare($value): int;
/**
* Check if $this is able to be compared to another value.
*
* A return value of false indicates that calling $this->compare($value)
* will throw an exception.
*
* @param mixed $value The value to compare.
*
* @return bool True if $this can be compared to $value.
*/
public function canCompare($value): bool;
}