MyQueryBuilder   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 32
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A avg() 0 9 2
A sum() 0 9 2
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
}