Completed
Branch 2.0-dev (8b7d5c)
by Takehiro
02:30
created

Lql::table()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 6
rs 9.4286
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
namespace Kwkm\MkLiveStatusClient;
3
4
/**
5
 * Class Lql
6
 *
7
 * @package Kwkm\MkLiveStatusClient
8
 * @author Takehiro Kawakami <[email protected]>
9
 * @license MIT
10
 */
11
class Lql
12
{
13
    private $table;
14
    private $authUser;
15
16
17
    /**
18
     * @var \Kwkm\MkLiveStatusClient\LqlObject
19
     */
20
    private $lqlObject;
21
22
    /**
23
     * 初期化
24
     *
25
     * @return \Kwkm\MkLiveStatusClient\Lql
26
     */
27
    public function reset()
28
    {
29
        $this->lqlObject = new LqlObject();
30
        $this->lqlObject->setTable($this->table);
31
        if (!is_null($this->authUser)) {
32
            $this->lqlObject->setAuthUser($this->authUser);
33
        }
34
35
        return $this;
36
    }
37
38
    /**
39
     * 取得カラムの指定
40
     *
41
     * @param string $column
42
     * @return \Kwkm\MkLiveStatusClient\Lql
43
     * @throw \InvalidArgumentException if the provided argument is not of type 'string'.
44
     */
45
    public function column($column)
46
    {
47
        $this->lqlObject->appendColumns($column);
48
49
        return $this;
50
    }
51
52
    /**
53
     * ヘッダ情報を取得するかの設定
54
     *
55
     * @param boolean $boolean
56
     * @return \Kwkm\MkLiveStatusClient\Lql
57
     * @throw \InvalidArgumentException if the provided argument is not of type 'boolean'.
58
     */
59
    public function headers($boolean)
60
    {
61
        $this->lqlObject->setHeader($boolean);
62
63
        return $this;
64
    }
65
66
    /**
67
     * 取得カラムの一括指定
68
     *
69
     * @param array $columns
70
     * @return \Kwkm\MkLiveStatusClient\Lql
71
     * @throw \InvalidArgumentException if the provided argument is not of type 'array'.
72
     */
73
    public function columns($columns)
74
    {
75
        $this->lqlObject->setColumns($columns);
76
77
        return $this;
78
    }
79
80
    /**
81
     * 任意のフィルタ設定
82
     *
83
     * @param \Kwkm\MkLiveStatusClient\Filter $filter
84
     * @return \Kwkm\MkLiveStatusClient\Lql
85
     * @throw \InvalidArgumentException if the provided argument is not of type 'string'.
86
     */
87
    public function filter(Filter $filter)
88
    {
89
        $this->lqlObject->appendFilterQuery($filter);
90
91
        return $this;
92
    }
93
94
    /**
95
     * Stats の指定
96
     * @param string $stats
97
     * @return \Kwkm\MkLiveStatusClient\Lql
98
     * @throw \InvalidArgumentException if the provided argument is not of type 'string'.
99
     */
100
    public function stats($stats)
101
    {
102
        $this->lqlObject->appendStringQuery('Stats', $stats);
103
104
        return $this;
105
    }
106
107
    /**
108
     * StatsAnd の指定
109
     * @param integer $statsAnd
110
     * @return \Kwkm\MkLiveStatusClient\Lql
111
     * @throw \InvalidArgumentException if the provided argument is not of type 'integer'.
112
     */
113
    public function statsAnd($statsAnd)
114
    {
115
        $this->lqlObject->appendIntegerQuery('StatsAnd', $statsAnd);
116
117
        return $this;
118
    }
119
120
    /**
121
     * StatsNegate の指定
122
     * @return \Kwkm\MkLiveStatusClient\Lql
123
     */
124
    public function statsNegate()
125
    {
126
        $this->lqlObject->appendNoValueQuery('StatsNegate');
127
128
        return $this;
129
    }
130
131
    /**
132
     * Negate の指定
133
     * @return \Kwkm\MkLiveStatusClient\Lql
134
     */
135
    public function negate()
136
    {
137
        $this->lqlObject->appendNoValueQuery('Negate');
138
139
        return $this;
140
    }
141
142
    /**
143
     * パラメータの指定
144
     * @param string $parameter
145
     * @return \Kwkm\MkLiveStatusClient\Lql
146
     * @throw \InvalidArgumentException if the provided argument is not of type 'string'.
147
     */
148
    public function parameter($parameter)
149
    {
150
        $this->lqlObject->appendParameter($parameter);
151
152
        return $this;
153
    }
154
155
    /**
156
     * OutputFormat の指定
157
     * @param string $outputFormat
158
     * @return \Kwkm\MkLiveStatusClient\Lql
159
     * @throw \InvalidArgumentException if the provided argument is not of type 'string'.
160
     */
161
    public function outputFormat($outputFormat)
162
    {
163
        $this->lqlObject->setOutputFormat($outputFormat);
164
165
        return $this;
166
    }
167
168
    /**
169
     * Limit の指定
170
     * @param integer $limit
171
     * @return \Kwkm\MkLiveStatusClient\Lql
172
     * @throw \InvalidArgumentException if the provided argument is not of type 'integer'.
173
     */
174
    public function limit($limit)
175
    {
176
        $this->lqlObject->setLimit($limit);
177
178
        return $this;
179
    }
180
181
    /**
182
     * Lqlの実行テキストの作成
183
     * @return string
184
     */
185
    public function build()
186
    {
187
        return $this->lqlObject->build();
188
    }
189
190
    /**
191
     * コンストラクタ
192
     */
193
    public function __construct($table, $authUser = null)
194
    {
195
        $this->table = $table;
196
        $this->authUser = $authUser;
197
        $this->reset();
198
    }
199
}