Passed
Push — 2.0-dev ( 0f4023...039993 )
by Takehiro
02:34
created

LqlBuilder::statsOr()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 6
ccs 0
cts 3
cp 0
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
crap 2
1
<?php
2
3
namespace Kwkm\MkLiveStatusClient;
4
5
/**
6
 * Class LqlBuilder
7
 *
8
 * @package Kwkm\MkLiveStatusClient
9
 * @author Takehiro Kawakami <[email protected]>
10
 * @license MIT
11
 */
12
class LqlBuilder extends LqlAbstract
13
{
14
    /**
15
     * @var \Kwkm\MkLiveStatusClient\LqlObject
16
     */
17
    private $lqlObject;
18
19
    /**
20
     * @var string
21
     */
22
    private $table;
23
24
    /**
25
     * @var string
26
     */
27
    private $authUser;
28
29
    /**
30
     * 初期化
31
     *
32
     * @return \Kwkm\MkLiveStatusClient\LqlBuilder
33
     */
34 17
    public function reset()
35
    {
36 17
        $this->lqlObject = new LqlObject();
37 17
        $this->lqlObject->setTable($this->table);
38 17
        if (!is_null($this->authUser)) {
39 1
            $this->lqlObject->setAuthUser($this->authUser);
40 1
        }
41
42 17
        return $this;
43
    }
44
45
    /**
46
     * 取得カラムの指定
47
     *
48
     * @param string $column
49
     * @return \Kwkm\MkLiveStatusClient\LqlBuilder
50
     * @throw \InvalidArgumentException if the provided argument is not of type 'string'.
51
     */
52 2
    public function column($column)
53
    {
54 2
        $this->lqlObject->appendColumns($column);
55
56 2
        return $this;
57
    }
58
59
    /**
60
     * ヘッダ情報を取得するかの設定
61
     *
62
     * @param boolean $boolean
63
     * @return \Kwkm\MkLiveStatusClient\LqlBuilder
64
     * @throw \InvalidArgumentException if the provided argument is not of type 'boolean'.
65
     */
66
    public function headers($boolean)
67
    {
68
        $this->lqlObject->setHeader($boolean);
69
70
        return $this;
71
    }
72
73
    /**
74
     * 取得カラムの一括指定
75
     *
76
     * @param array $columns
77
     * @return \Kwkm\MkLiveStatusClient\LqlBuilder
78
     * @throw \InvalidArgumentException if the provided argument is not of type 'array'.
79
     */
80 7
    public function columns($columns)
81
    {
82 7
        $this->lqlObject->setColumns($columns);
83
84 7
        return $this;
85
    }
86
87
    /**
88
     * 任意のフィルタ設定
89
     *
90
     * @param string $filter
91
     * @return \Kwkm\MkLiveStatusClient\LqlBuilder
92
     * @throw \InvalidArgumentException if the provided argument is not of type 'string'.
93
     */
94 13
    public function filter($filter)
95
    {
96 13
        $this->lqlObject->appendStringQuery('Filter', trim($filter));
97
98 13
        return $this;
99
    }
100
101
    /**
102
     * column = value のフィルタ設定
103
     *
104
     * @param string $column カラム名
105
     * @param string $value フィルタする値
106
     * @return \Kwkm\MkLiveStatusClient\LqlBuilder
107
     */
108 7
    public function filterEqual($column, $value)
109
    {
110 7
        return $this->filter(
111 7
            sprintf("%s = %s", $column, $value)
112 7
        );
113
    }
114
115
    /**
116
     * column ~ value のフィルタ設定
117
     *
118
     * @param string $column カラム名
119
     * @param string $value フィルタする値
120
     * @return \Kwkm\MkLiveStatusClient\LqlBuilder
121
     */
122 2
    public function filterMatch($column, $value)
123
    {
124 2
        return $this->filter(
125 2
            sprintf("%s ~ %s", $column, $value)
126 2
        );
127
    }
128
129
    /**
130
     * column != value のフィルタ設定
131
     *
132
     * @param string $column カラム名
133
     * @param string $value フィルタする値
134
     * @return \Kwkm\MkLiveStatusClient\LqlBuilder
135
     */
136 1
    public function filterNotEqual($column, $value)
137
    {
138 1
        return $this->filter(
139 1
            sprintf("%s != %s", $column, $value)
140 1
        );
141
    }
142
143
    /**
144
     * column !~ value のフィルタ設定
145
     *
146
     * @param string $column カラム名
147
     * @param string $value フィルタする値
148
     * @return \Kwkm\MkLiveStatusClient\LqlBuilder
149
     */
150
    public function filterNotMatch($column, $value)
151
    {
152
        return $this->filter(
153
            sprintf("%s !~ %s", $column, $value)
154
        );
155
    }
156
157
    /**
158
     * column < value のフィルタ設定
159
     *
160
     * @param string $column カラム名
161
     * @param string $value フィルタする値
162
     * @return \Kwkm\MkLiveStatusClient\LqlBuilder
163
     */
164
    public function filterLess($column, $value)
165
    {
166
        return $this->filter(
167
            sprintf("%s < %s", $column, $value)
168
        );
169
    }
170
171
    /**
172
     * column > value のフィルタ設定
173
     *
174
     * @param string $column カラム名
175
     * @param string $value フィルタする値
176
     * @return \Kwkm\MkLiveStatusClient\LqlBuilder
177
     */
178 1
    public function filterGreater($column, $value)
179
    {
180 1
        return $this->filter(
181 1
            sprintf("%s > %s", $column, $value)
182 1
        );
183
    }
184
185
    /**
186
     * column <= value のフィルタ設定
187
     *
188
     * @param string $column カラム名
189
     * @param string $value フィルタする値
190
     * @return \Kwkm\MkLiveStatusClient\LqlBuilder
191
     */
192
    public function filterLessEqual($column, $value)
193
    {
194
        return $this->filter(
195
            sprintf("%s <= %s", $column, $value)
196
        );
197
    }
198
199
    /**
200
     * column >= value のフィルタ設定
201
     *
202
     * @param string $column カラム名
203
     * @param string $value フィルタする値
204
     * @return \Kwkm\MkLiveStatusClient\LqlBuilder
205
     */
206 3
    public function filterGreaterEqual($column, $value)
207
    {
208 3
        return $this->filter(
209 3
            sprintf("%s >= %s", $column, $value)
210 3
        );
211
    }
212
213
    /**
214
     * Stats の指定
215
     * @param string $stats
216
     * @return \Kwkm\MkLiveStatusClient\LqlBuilder
217
     * @throw \InvalidArgumentException if the provided argument is not of type 'string'.
218
     */
219 3
    public function stats($stats)
220
    {
221 3
        $this->lqlObject->appendStringQuery('Stats', $stats);
222
223 3
        return $this;
224
    }
225
226
    /**
227
     * column = value のStats設定
228
     *
229
     * @param string $column カラム名
230
     * @param string $value フィルタする値
231
     * @return \Kwkm\MkLiveStatusClient\LqlBuilder
232
     */
233 3
    public function statsEqual($column, $value)
234
    {
235 3
        return $this->stats(
236 3
            sprintf("%s = %s", $column, $value)
237 3
        );
238
    }
239
240
    /**
241
     * column != value のStats設定
242
     *
243
     * @param string $column カラム名
244
     * @param string $value フィルタする値
245
     * @return \Kwkm\MkLiveStatusClient\LqlBuilder
246
     */
247
    public function statsNotEqual($column, $value)
248
    {
249
        return $this->filter(
250
            sprintf("%s != %s", $column, $value)
251
        );
252
    }
253
254
    /**
255
     * StatsAnd の指定
256
     * @param integer $statsAnd
257
     * @return \Kwkm\MkLiveStatusClient\LqlBuilder
258
     * @throw \InvalidArgumentException if the provided argument is not of type 'integer'.
259
     */
260 1
    public function statsAnd($statsAnd)
261
    {
262 1
        $this->lqlObject->appendIntegerQuery('StatsAnd', $statsAnd);
263
264 1
        return $this;
265
    }
266
267
    /**
268
     * StatsOr の指定
269
     * @param integer $statsAnd
0 ignored issues
show
Bug introduced by
There is no parameter named $statsAnd. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
270
     * @return \Kwkm\MkLiveStatusClient\LqlBuilder
271
     * @throw \InvalidArgumentException if the provided argument is not of type 'integer'.
272
     */
273
    public function statsOr($statsOr)
274
    {
275
        $this->lqlObject->appendIntegerQuery('StatsOr', $statsOr);
276
277
        return $this;
278
    }
279
280
    /**
281
     * StatsNegate の指定
282
     * @return \Kwkm\MkLiveStatusClient\LqlBuilder
283
     */
284
    public function statsNegate()
285
    {
286
        $this->lqlObject->appendNoValueQuery('StatsNegate');
287
288
        return $this;
289
    }
290
291
    /**
292
     * Or の指定
293
     * @param integer $or
294
     * @return \Kwkm\MkLiveStatusClient\LqlBuilder
295
     * @throw \InvalidArgumentException if the provided argument is not of type 'integer'.
296
     */
297 4
    public function filterOr($or)
298
    {
299 4
        $this->lqlObject->appendIntegerQuery('Or', $or);
300
301 4
        return $this;
302
    }
303
304
    /**
305
     * And の指定
306
     * @param integer $and
307
     * @return \Kwkm\MkLiveStatusClient\LqlBuilder
308
     * @throw \InvalidArgumentException if the provided argument is not of type 'integer'.
309
     */
310 1
    public function filterAnd($and)
311
    {
312 1
        $this->lqlObject->appendIntegerQuery('And', $and);
313
314 1
        return $this;
315
    }
316
317
    /**
318
     * Negate の指定
319
     * @return \Kwkm\MkLiveStatusClient\LqlBuilder
320
     */
321 1
    public function negate()
322
    {
323 1
        $this->lqlObject->appendNoValueQuery('Negate');
324
325 1
        return $this;
326
    }
327
328
    /**
329
     * パラメータの指定
330
     * @param string $parameter
331
     * @return \Kwkm\MkLiveStatusClient\LqlBuilder
332
     * @throw \InvalidArgumentException if the provided argument is not of type 'string'.
333
     */
334
    public function parameter($parameter)
335
    {
336
        $this->lqlObject->appendParameter($parameter);
337
338
        return $this;
339
    }
340
341
    /**
342
     * OutputFormat の指定
343
     * @param string $outputFormat
344
     * @return \Kwkm\MkLiveStatusClient\LqlBuilder
345
     * @throw \InvalidArgumentException if the provided argument is not of type 'string'.
346
     */
347
    public function outputFormat($outputFormat)
348
    {
349
        $this->lqlObject->setOutputFormat($outputFormat);
350
351
        return $this;
352
    }
353
354
    /**
355
     * Limit の指定
356
     * @param integer $limit
357
     * @return \Kwkm\MkLiveStatusClient\LqlBuilder
358
     * @throw \InvalidArgumentException if the provided argument is not of type 'integer'.
359
     */
360
    public function limit($limit)
361
    {
362
        $this->lqlObject->setLimit($limit);
363
364
        return $this;
365
    }
366
367
    /**
368
     * Lqlの実行テキストの作成
369
     * @return string
370
     */
371 17
    public function build()
372
    {
373 17
        return $this->lqlObject->build();
374
    }
375
376
    /**
377
     * コンストラクタ
378
     */
379 17
    public function __construct($table, $authUser = null)
380
    {
381 17
        $this->table = $table;
382 17
        $this->authUser = $authUser;
383 17
        $this->reset();
384 17
    }
385
}
386