JoinBuilder   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 7
c 1
b 0
f 0
dl 0
loc 40
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A orOn() 0 3 1
A on() 0 3 1
A joinHandler() 0 7 1
1
<?php
2
3
namespace Pixie\QueryBuilder;
4
5
class JoinBuilder extends QueryBuilderHandler
6
{
7
    /**
8
     * @param string|Raw $key
9
     * @param string|null $operator
10
     * @param mixed $value
11
     *
12
     * @return static
13
     */
14
    public function on($key, ?string $operator, $value): self
15
    {
16
        return $this->joinHandler($key, $operator, $value, 'AND');
17
    }
18
19
    /**
20
     * @param string|Raw $key
21
     * @param string|null $operator
22
     * @param mixed $value
23
     *
24
     * @return static
25
     */
26
    public function orOn($key, ?string $operator, $value): self
27
    {
28
        return $this->joinHandler($key, $operator, $value, 'OR');
29
    }
30
31
    /**
32
     * @param string|Raw $key
33
     * @param string|null $operator
34
     * @param mixed $value
35
     *
36
     * @return static
37
     */
38
    protected function joinHandler($key, ?string $operator = null, $value = null, string $joiner = 'AND'): self
39
    {
40
        $key                            = $this->addTablePrefix($key);
41
        $value                          = $this->addTablePrefix($value);
42
        $this->statements['criteria'][] = compact('key', 'operator', 'value', 'joiner');
43
44
        return $this;
45
    }
46
}
47