Test Setup Failed
Branch master (10fdc5)
by Beniamin
35:44
created

AbstractTable   A

Complexity

Total Complexity 17

Size/Duplication

Total Lines 166
Duplicated Lines 0 %

Coupling/Cohesion

Components 3
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 166
c 0
b 0
f 0
wmc 17
lcom 3
cbo 1
rs 10

16 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A __toString() 0 4 1
A getAliasOrName() 0 4 2
A getQueryBuilder() 0 4 1
A getAlias() 0 4 1
A setAlias() 0 6 1
A isJoin() 0 4 1
A getJoinType() 0 4 1
A setJoinType() 0 4 1
A joinOn() 0 4 1
A getJoinOn() 0 4 1
A isOuterJoin() 0 4 1
A setOuterJoin() 0 4 1
A isNaturalJoin() 0 4 1
A setNaturalJoin() 0 4 1
A column() 0 4 1
1
<?php
2
3
namespace Phuria\UnderQuery\Table;
4
5
use Phuria\UnderQuery\QueryBuilder\BuilderInterface;
6
7
/**
8
 * @author Beniamin Jonatan Šimko <[email protected]>
9
 */
10
abstract class AbstractTable implements TableInterface
11
{
12
    /**
13
     * @var BuilderInterface
14
     */
15
    private $qb;
16
17
    /**
18
     * @var string
19
     */
20
    private $tableAlias;
21
22
    /**
23
     * @var int
24
     */
25
    private $joinType;
26
27
    /**
28
     * @var string
29
     */
30
    private $joinOn;
31
32
    /**
33
     * @var bool
34
     */
35
    private $outerJoin = false;
36
37
    /**
38
     * @var bool
39
     */
40
    private $naturalJoin = false;
41
42
    /**
43
     * @param BuilderInterface $qb
44
     */
45
    public function __construct(BuilderInterface $qb)
46
    {
47
        $this->qb = $qb;
48
    }
49
50
    /**
51
     * @return string
52
     */
53
    public function __toString()
54
    {
55
        return $this->getQueryBuilder()->objectToString($this);
56
    }
57
58
    /**
59
     * @inheritdoc
60
     */
61
    public function getAliasOrName()
62
    {
63
        return $this->getAlias() ?: $this->getTableName();
64
    }
65
66
    /**
67
     * @return BuilderInterface
68
     */
69
    public function getQueryBuilder()
70
    {
71
        return $this->qb;
72
    }
73
74
    /**
75
     * @return string
76
     */
77
    public function getAlias()
78
    {
79
        return $this->tableAlias;
80
    }
81
82
    /**
83
     * @param string $alias
84
     *
85
     * @return $this
86
     */
87
    public function setAlias($alias)
88
    {
89
        $this->tableAlias = $alias;
90
91
        return $this;
92
    }
93
94
    /**
95
     * @return bool
96
     */
97
    public function isJoin()
98
    {
99
        return (bool) $this->joinType;
100
    }
101
102
    /**
103
     * @return int
104
     */
105
    public function getJoinType()
106
    {
107
        return $this->joinType;
108
    }
109
110
    /**
111
     * @param int $joinType
112
     */
113
    public function setJoinType($joinType)
114
    {
115
        $this->joinType = $joinType;
116
    }
117
118
    /**
119
     * @param string $clause
120
     */
121
    public function joinOn($clause)
122
    {
123
        $this->joinOn = $clause;
124
    }
125
126
    /**
127
     * @return string
128
     */
129
    public function getJoinOn()
130
    {
131
        return $this->joinOn;
132
    }
133
134
    /**
135
     * @return boolean
136
     */
137
    public function isOuterJoin()
138
    {
139
        return $this->outerJoin;
140
    }
141
142
    /**
143
     * @param boolean $outerJoin
144
     */
145
    public function setOuterJoin($outerJoin)
146
    {
147
        $this->outerJoin = $outerJoin;
148
    }
149
150
    /**
151
     * @return boolean
152
     */
153
    public function isNaturalJoin()
154
    {
155
        return $this->naturalJoin;
156
    }
157
158
    /**
159
     * @param boolean $naturalJoin
160
     */
161
    public function setNaturalJoin($naturalJoin)
162
    {
163
        $this->naturalJoin = $naturalJoin;
164
    }
165
166
    /**
167
     * @param string $name
168
     *
169
     * @return string
170
     */
171
    public function column($name)
172
    {
173
        return $this . '.' . $name;
174
    }
175
}