1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Pinq; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* The API defining all the aggregate results, |
7
|
|
|
* mainly exists for organizational purposes |
8
|
|
|
* |
9
|
|
|
* @author Elliot Levin <[email protected]> |
10
|
|
|
*/ |
11
|
|
|
interface IAggregatable extends \Countable |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* Returns the amount of the values. |
15
|
|
|
* |
16
|
|
|
* @return int |
17
|
|
|
*/ |
18
|
|
|
public function count(); |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Returns whether the traversable contains no elements. |
22
|
|
|
* |
23
|
|
|
* @return boolean |
24
|
|
|
*/ |
25
|
|
|
public function isEmpty(); |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Aggregates the values with the supplied function. |
29
|
|
|
* |
30
|
|
|
* @param callable $function The aggregate function, parameters: ($aggregate, $step) |
31
|
|
|
* |
32
|
|
|
* @return mixed |
33
|
|
|
*/ |
34
|
|
|
public function aggregate(callable $function); |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Returns the maximum value. |
38
|
|
|
* |
39
|
|
|
* @param callable $function The function which will return the values. |
40
|
|
|
* |
41
|
|
|
* @return mixed |
42
|
|
|
*/ |
43
|
|
|
public function maximum(callable $function = null); |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Returns the maximum value. |
47
|
|
|
* |
48
|
|
|
* @param callable $function The function which will return the values. |
49
|
|
|
* |
50
|
|
|
* @return mixed |
51
|
|
|
*/ |
52
|
|
|
public function minimum(callable $function = null); |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Returns the sum of the values. |
56
|
|
|
* |
57
|
|
|
* @param callable $function The function which will return the values. |
58
|
|
|
* |
59
|
|
|
* @return int|double|null |
60
|
|
|
*/ |
61
|
|
|
public function sum(callable $function = null); |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Returns the average of the values. |
65
|
|
|
* |
66
|
|
|
* @param callable $function The function which will return the values. |
67
|
|
|
* |
68
|
|
|
* @return int|double|null |
69
|
|
|
*/ |
70
|
|
|
public function average(callable $function = null); |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Returns a boolean of if all the values evaluate to true. |
74
|
|
|
* |
75
|
|
|
* @param callable $function The function which will return the values. |
76
|
|
|
* |
77
|
|
|
* @return bool |
78
|
|
|
*/ |
79
|
|
|
public function all(callable $function = null); |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Returns a boolean of if any of the values evaluate to true. |
83
|
|
|
* |
84
|
|
|
* @param callable $function The function which will return the values. |
85
|
|
|
* |
86
|
|
|
* @return bool |
87
|
|
|
*/ |
88
|
|
|
public function any(callable $function = null); |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* Returns a string of all the values concatenated by the delimiter. |
92
|
|
|
* |
93
|
|
|
* @param string $delimiter The string to delimit the values by. |
94
|
|
|
* @param callable $function The function which will return the values. |
95
|
|
|
* |
96
|
|
|
* @return string |
97
|
|
|
*/ |
98
|
|
|
public function implode($delimiter, callable $function = null); |
99
|
|
|
} |
100
|
|
|
|