Total Complexity | 10 |
Total Lines | 88 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
8 | trait AggregateTrait { |
||
9 | |||
10 | use AbstractTrait; |
||
11 | |||
12 | /** |
||
13 | * `AVG($this)` |
||
14 | * |
||
15 | * @return Num |
||
16 | */ |
||
17 | public function avg () { |
||
18 | return Num::factory($this->db, "AVG({$this})"); |
||
19 | } |
||
20 | |||
21 | /** |
||
22 | * `AVG(DISTINCT $this)` |
||
23 | * |
||
24 | * @return Num |
||
25 | */ |
||
26 | public function avgDistinct () { |
||
28 | } |
||
29 | |||
30 | /** |
||
31 | * `COUNT($this)` |
||
32 | * |
||
33 | * @return Num |
||
34 | */ |
||
35 | public function count () { |
||
36 | return Num::factory($this->db, "COUNT({$this})"); |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * `COUNT(DISTINCT $this)` |
||
41 | * |
||
42 | * @return Num |
||
43 | */ |
||
44 | public function countDistinct () { |
||
45 | return Num::factory($this->db, "COUNT(DISTINCT {$this})"); |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * `GROUP_CONCAT($this)` using a delimiter. |
||
50 | * |
||
51 | * @param string $delimiter |
||
52 | * @return Text |
||
53 | */ |
||
54 | public function groupConcat (string $delimiter = ',') { |
||
55 | $delimiter = $this->db->quote($delimiter); |
||
56 | if ($this->db->isSQLite()) { |
||
57 | return Text::factory($this->db, "GROUP_CONCAT({$this},{$delimiter})"); |
||
58 | } |
||
59 | return Text::factory($this->db, "GROUP_CONCAT({$this} SEPARATOR {$delimiter})"); |
||
60 | } |
||
61 | |||
62 | /** |
||
63 | * `MAX($this)` |
||
64 | * |
||
65 | * @return Num |
||
66 | */ |
||
67 | public function max () { |
||
68 | return Num::factory($this->db, "MAX({$this})"); |
||
69 | } |
||
70 | |||
71 | /** |
||
72 | * `MIN($this)` |
||
73 | * |
||
74 | * @return Num |
||
75 | */ |
||
76 | public function min () { |
||
77 | return Num::factory($this->db, "MIN({$this})"); |
||
78 | } |
||
79 | |||
80 | /** |
||
81 | * `SUM($this)` |
||
82 | * |
||
83 | * @return Num |
||
84 | */ |
||
85 | public function sum () { |
||
86 | return Num::factory($this->db, "SUM({$this})"); |
||
87 | } |
||
88 | |||
89 | /** |
||
90 | * `SUM(DISTINCT $this)` |
||
91 | * |
||
92 | * @return Num |
||
93 | */ |
||
94 | public function sumDistinct () { |
||
96 | } |
||
97 | } |