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.
Passed
Push — master ( 7b036e...114130 )
by
unknown
02:35
created

QueryBuilderCache   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 189
Duplicated Lines 0 %

Importance

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

7 Methods

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