Completed
Push — master ( f1592e...b3630f )
by Daniel
03:25 queued 01:30
created

Join   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 0
dl 0
loc 55
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 14 2
A getType() 0 4 1
A getAlias() 0 4 1
A getJoin() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Psi\Component\ObjectAgent\Query;
6
7
class Join
8
{
9
    const INNER_JOIN = 'INNER';
10
    const LEFT_JOIN = 'LEFT';
11
12
    private static $validTypes = [
13
        self::INNER_JOIN,
14
        self::LEFT_JOIN,
15
    ];
16
17
    /**
18
     * @var string
19
     */
20
    private $join;
21
22
    /**
23
     * @var string
24
     */
25
    private $type;
26
27
    /**
28
     * @var string
29
     */
30
    private $alias;
31
32
    public function __construct(string $join, string $alias, string $type = self::INNER_JOIN)
33
    {
34
        if (!in_array($type, self::$validTypes)) {
35
            throw new \InvalidArgumentException(sprintf(
36
                'Unknown join type "%s". Known joins: "%s"',
37
                $type,
38
                implode('", "', self::$validTypes)
39
            ));
40
        }
41
42
        $this->type = $type;
43
        $this->alias = $alias;
44
        $this->join = $join;
45
    }
46
47
    public function getType()
48
    {
49
        return $this->type;
50
    }
51
52
    public function getAlias()
53
    {
54
        return $this->alias;
55
    }
56
57
    public function getJoin()
58
    {
59
        return $this->join;
60
    }
61
}
62