GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

BuilderCache   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 188
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 7
eloc 95
c 0
b 0
f 0
dl 0
loc 188
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A setStatement() 0 3 1
A resetRun() 0 27 1
A reset() 0 6 1
A __construct() 0 27 1
A getStatement() 0 3 1
A resetGetter() 0 26 1
A resetModifier() 0 19 1
1
<?php
2
/**
3
 * This file is part of the O2System Framework package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 *
8
 * @author         Steeve Andrian Salim
9
 * @copyright      Copyright (c) Steeve Andrian Salim
10
 */
11
12
// ------------------------------------------------------------------------
13
14
namespace O2System\Database\Sql\DataStructures\Query;
15
16
// ------------------------------------------------------------------------
17
18
/**
19
 * Class BuilderCache
20
 *
21
 * @package O2System\Database\Sql\DataStructures\Query
22
 */
23
class BuilderCache extends \ArrayObject
24
{
25
    /**
26
     * BuilderCache::__construct
27
     */
28
    public function __construct()
29
    {
30
        parent::__construct([
31
            'select'        => [],
32
            'union'         => [],
33
            'unionAll'      => [],
34
            'into'          => false,
35
            'distinct'      => false,
36
            'from'          => [],
37
            'join'          => [],
38
            'where'         => [],
39
            'having'        => [],
40
            'between'       => [],
41
            'notBetween'    => [],
42
            'limit'         => false,
43
            'offset'        => false,
44
            'groupBy'       => [],
45
            'orderBy'       => [],
46
            'keys'          => [],
47
            'sets'          => [],
48
            'binds'         => [],
49
            'aliasedTables' => [],
50
            'noEscape'      => [],
51
            'bracketOpen'   => false,
52
            'bracketCount'  => 0,
53
            'statement'     => null,
54
        ], \ArrayObject::ARRAY_AS_PROPS);
55
    }
56
57
    // ------------------------------------------------------------------------
58
59
    /**
60
     * BuilderCache::setStatement
61
     *
62
     * Set Statement Query Builder cache
63
     *
64
     * @param string $statement
65
     */
66
    public function setStatement($statement)
67
    {
68
        $this->offsetSet('statement', trim($statement));
69
    }
70
71
    // ------------------------------------------------------------------------
72
73
    /**
74
     * BuilderCache::getStatement
75
     *
76
     * Get Statement Query Builder cache
77
     *
78
     * @return string
79
     */
80
    public function getStatement()
81
    {
82
        return $this->offsetGet('statement');
83
    }
84
85
    // ------------------------------------------------------------------------
86
87
    /**
88
     * BuilderCache::reset
89
     *
90
     * Reset Query Builder cache.
91
     *
92
     * @return  static
93
     */
94
    public function reset()
95
    {
96
        $this->resetGetter();
97
        $this->resetModifier();
98
99
        return $this;
100
    }
101
102
    // ------------------------------------------------------------------------
103
104
    /**
105
     * BuilderCache::resetGetter
106
     *
107
     * Resets the query builder values.  Called by the get() function
108
     *
109
     * @return  void
110
     */
111
    public function resetGetter()
112
    {
113
        $this->resetRun(
114
            [
115
                'select'        => [],
116
                'union'         => [],
117
                'unionAll'      => [],
118
                'into'          => false,
119
                'distinct'      => false,
120
                'from'          => [],
121
                'join'          => [],
122
                'where'         => [],
123
                'having'        => [],
124
                'between'       => [],
125
                'notBetween'    => [],
126
                'limit'         => false,
127
                'offset'        => false,
128
                'groupBy'       => [],
129
                'orderBy'       => [],
130
                'keys'          => [],
131
                'binds'         => [],
132
                'aliasedTables' => [],
133
                'noEscape'      => [],
134
                'bracketOpen'   => false,
135
                'bracketCount'  => 0,
136
                'statement'     => null,
137
            ]
138
        );
139
    }
140
141
    // ------------------------------------------------------------------------
142
143
    /**
144
     * BuilderCache::resetRun
145
     *
146
     * Resets the query builder values.  Called by the get() function
147
     *
148
     * @param array $cacheKeys An array of fields to reset
149
     *
150
     * @return  void
151
     */
152
    protected function resetRun(array $cacheKeys)
153
    {
154
        parent::__construct(array_merge([
155
            'select'        => [],
156
            'union'         => [],
157
            'unionAll'      => [],
158
            'into'          => false,
159
            'distinct'      => false,
160
            'from'          => [],
161
            'join'          => [],
162
            'where'         => [],
163
            'having'        => [],
164
            'between'       => [],
165
            'notBetween'    => [],
166
            'limit'         => false,
167
            'offset'        => false,
168
            'groupBy'       => [],
169
            'orderBy'       => [],
170
            'keys'          => [],
171
            'sets'          => [],
172
            'binds'         => [],
173
            'aliasedTables' => [],
174
            'noEscape'      => [],
175
            'bracketOpen'   => false,
176
            'bracketCount'  => 0,
177
            'statement'     => null,
178
        ], $cacheKeys), \ArrayObject::ARRAY_AS_PROPS);
179
    }
180
181
    // ------------------------------------------------------------------------
182
183
    /**
184
     * BuilderCache::resetModifier
185
     *
186
     * Resets the query builder "modifier" values.
187
     *
188
     * Called by the insert() update() insertBatch() updateBatch() and delete() functions
189
     *
190
     * @return  void
191
     */
192
    public function resetModifier()
193
    {
194
        $this->resetRun(
195
            [
196
                'from'          => [],
197
                'binds'         => [],
198
                'sets'          => [],
199
                'join'          => [],
200
                'where'         => [],
201
                'having'        => [],
202
                'between'       => [],
203
                'notBetween'    => [],
204
                'keys'          => [],
205
                'limit'         => false,
206
                'aliasedTables' => [],
207
                'noEscape'      => [],
208
                'bracketOpen'   => false,
209
                'bracketCount'  => 0,
210
                'statement'     => null,
211
            ]
212
        );
213
    }
214
}
215