Total Complexity | 3 |
Total Lines | 34 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
10 | class Comparators |
||
11 | { |
||
12 | /** |
||
13 | * Returns <Fn($a: scalar, $b: scalar): int> for scalar value compares such as int, bool, float, string |
||
14 | * @return callable |
||
15 | */ |
||
16 | 6 | public static function scalarComparator(): Closure |
|
17 | { |
||
18 | return static function ($a, $b) { |
||
19 | 6 | return $a <=> $b; |
|
20 | 6 | }; |
|
21 | } |
||
22 | |||
23 | /** |
||
24 | * Returns <Fn($a: object, $b: object): int> for scalar object property value compares such as int, bool, float, string |
||
25 | * @param string $property |
||
26 | * @return callable |
||
27 | */ |
||
28 | 6 | public static function objectPropertyComparator(string $property): Closure |
|
32 | 6 | }; |
|
33 | } |
||
34 | |||
35 | /** |
||
36 | * Returns <Fn($a: scalar, $b: scalar): int> for scalar value compares such as int, bool, float, string |
||
37 | * @param callable $f <Fn(value: mixed): scalar> |
||
38 | * @return Closure |
||
39 | */ |
||
40 | 7 | public static function callbackComparator(callable $f): Closure |
|
47 |