MyQueryBuilder::avg()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 2
dl 0
loc 9
rs 10
c 0
b 0
f 0
1
<?php
2
3
use ElePHPant\LightQueryBuilder;
4
5
/**
6
 * Class MyQueryBuilder
7
 */
8
class MyQueryBuilder extends LightQueryBuilder
9
{
10
    /**
11
     * @param string $column
12
     * @param string|null $condition
13
     * @return MyQueryBuilder
14
     */
15
    public function avg(string $column, ?string $condition): self
16
    {
17
        $select = $this->select("AVG({$column})");
18
19
        if ($condition) {
20
            return $select->where($condition);
21
        }
22
23
        return $select;
24
    }
25
26
    /**
27
     * @param string $columns
28
     * @param string $condition
29
     * @return MyQueryBuilder
30
     */
31
    public function sum(string $columns, string $condition): self
32
    {
33
        $select = $this->select("SUM({$columns})");
34
35
        if ($condition) {
36
            return $select->where($condition);
37
        }
38
39
        return $select;
40
    }
41
42
}