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::store()   A

Complexity

Conditions 5
Paths 5

Size

Total Lines 17
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 17
rs 9.6111
c 0
b 0
f 0
cc 5
nc 5
nop 2
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\NoSql\DataStructures;
15
16
// ------------------------------------------------------------------------
17
18
/**
19
 * Class QueryBuilderCache
20
 *
21
 * @package O2System\Database\Sql\DataStructures
22
 */
23
class QueryBuilderCache
24
{
25
    /**
26
     * QueryBuilderCache::$storage
27
     *
28
     * Query builder cache.
29
     *
30
     * @var array
31
     */
32
    protected $vars
33
        = [
34
            'select'       => [],
35
            'from'         => null,
36
            'join'         => [],
37
            'where'        => [],
38
            'orWhere'      => [],
39
            'whereNot'     => [],
40
            'orWhereNot'   => [],
41
            'whereIn'      => [],
42
            'orWhereIn'    => [],
43
            'whereNotIn'   => [],
44
            'orWhereNotIn' => [],
45
            'having'       => [],
46
            'orHaving'     => [],
47
            'between'      => [],
48
            'orBetween'    => [],
49
            'notBetween'   => [],
50
            'orNotBetween' => [],
51
            'like'         => [],
52
            'notLike'      => [],
53
            'orLike'       => [],
54
            'orNotLike'    => [],
55
            'limit'        => 0,
56
            'offset'       => 0,
57
            'groupBy'      => [],
58
            'orderBy'      => [],
59
            'sets'         => [],
60
        ];
61
62
    /**
63
     * QueryBuilderCache::$statement
64
     *
65
     * Query builder cache statement.
66
     *
67
     * @var string
68
     */
69
    protected $statement;
70
71
    // ------------------------------------------------------------------------
72
73
    /**
74
     * QueryBuilderCache::__get
75
     *
76
     *
77
     * @param  string $property
78
     *
79
     * @return mixed
80
     */
81
    public function &__get($property)
82
    {
83
        return $this->vars[ $property ];
84
    }
85
86
    // ------------------------------------------------------------------------
87
88
    /**
89
     * QueryBuilderCache::store
90
     *
91
     * @param  string|bool $index
92
     * @param  array|bool  $value
93
     *
94
     * @return static
95
     */
96
    public function store($index, $value)
97
    {
98
        if (array_key_exists($index, $this->vars)) {
99
            if (is_array($this->vars[ $index ])) {
100
                if (is_array($value)) {
101
                    $this->vars[ $index ] = array_merge($this->vars[ $index ], $value);
102
                } else {
103
                    array_push($this->vars[ $index ], $value);
104
                }
105
            } elseif (is_bool($this->vars[ $index ])) {
106
                $this->vars[ $index ] = (bool)$value;
107
            } else {
108
                $this->vars[ $index ] = $value;
109
            }
110
        }
111
112
        return $this;
113
    }
114
115
    // ------------------------------------------------------------------------
116
117
    /**
118
     * QueryBuilderCache::getStatement
119
     *
120
     * Get Statement Query Builder cache
121
     *
122
     * @return string
123
     */
124
    public function getStatement()
125
    {
126
        return $this->statement;
127
    }
128
129
    // ------------------------------------------------------------------------
130
131
    /**
132
     * QueryBuilderCache::setStatement
133
     *
134
     * Set Statement Query Builder cache
135
     *
136
     * @param string $statement
137
     */
138
    public function setStatement($statement)
139
    {
140
        $this->statement = trim($statement);
141
    }
142
143
    // ------------------------------------------------------------------------
144
145
    /**
146
     * QueryBuilderCache::reset
147
     *
148
     * Reset Query Builder cache.
149
     *
150
     * @return  static
151
     */
152
    public function reset()
153
    {
154
        $this->resetGetter();
155
        $this->resetModifier();
156
157
        return $this;
158
    }
159
160
    // ------------------------------------------------------------------------
161
162
    /**
163
     * QueryBuilderCache::resetGetter
164
     *
165
     * Resets the query builder values.  Called by the get() function
166
     *
167
     * @return  void
168
     */
169
    public function resetGetter()
170
    {
171
        $this->resetRun(
172
            [
173
                'select'       => [],
174
                'from'         => null,
175
                'join'         => [],
176
                'where'        => [],
177
                'orWhere'      => [],
178
                'whereNot'     => [],
179
                'orWhereNot'   => [],
180
                'whereIn'      => [],
181
                'orWhereIn'    => [],
182
                'whereNotIn'   => [],
183
                'orWhereNotIn' => [],
184
                'having'       => [],
185
                'orHaving'     => [],
186
                'between'      => [],
187
                'orBetween'    => [],
188
                'notBetween'   => [],
189
                'orNotBetween' => [],
190
                'like'         => [],
191
                'notLike'      => [],
192
                'orLike'       => [],
193
                'orNotLike'    => [],
194
                'limit'        => 0,
195
                'offset'       => 0,
196
                'groupBy'      => [],
197
                'orderBy'      => [],
198
            ]
199
        );
200
    }
201
202
    // ------------------------------------------------------------------------
203
204
    /**
205
     * QueryBuilderCache::resetRun
206
     *
207
     * Resets the query builder values.  Called by the get() function
208
     *
209
     * @param   array $cacheKeys An array of fields to reset
210
     *
211
     * @return  void
212
     */
213
    protected function resetRun(array $cacheKeys)
214
    {
215
        foreach ($cacheKeys as $cacheKey => $cacheDefaultValue) {
216
            $this->vars[ $cacheKey ] = $cacheDefaultValue;
217
        }
218
    }
219
220
    // ------------------------------------------------------------------------
221
222
    /**
223
     * QueryBuilderCache::resetModifier
224
     *
225
     * Resets the query builder "modifier" values.
226
     *
227
     * Called by the insert() update() insertBatch() updateBatch() and delete() functions
228
     *
229
     * @return  void
230
     */
231
    public function resetModifier()
232
    {
233
        $this->resetRun(
234
            [
235
                'from'         => null,
236
                'join'         => [],
237
                'where'        => [],
238
                'orWhere'      => [],
239
                'whereNot'     => [],
240
                'orWhereNot'   => [],
241
                'whereIn'      => [],
242
                'orWhereIn'    => [],
243
                'whereNotIn'   => [],
244
                'orWhereNotIn' => [],
245
                'having'       => [],
246
                'orHaving'     => [],
247
                'between'      => [],
248
                'orBetween'    => [],
249
                'notBetween'   => [],
250
                'orNotBetween' => [],
251
                'like'         => [],
252
                'notLike'      => [],
253
                'orLike'       => [],
254
                'orNotLike'    => [],
255
                'limit'        => 0,
256
                'sets'         => [],
257
            ]
258
        );
259
    }
260
}
261