Lql::column()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
crap 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 extends LqlAbstract
12
{
13
    /**
14
     * @var \Kwkm\MkLiveStatusClient\LqlObject
15
     */
16
    private $lqlObject;
17
18
    /**
19
     * @var string
20
     */
21
    private $table;
22
23
    /**
24
     * @var string
25
     */
26
    private $authUser;
27
28
    /**
29
     * 初期化
30
     *
31
     * @return \Kwkm\MkLiveStatusClient\Lql
32
     */
33 42
    public function reset()
34
    {
35 42
        $this->lqlObject = new LqlObject();
36 42
        $this->lqlObject->setTable($this->table);
37 42
        if (!is_null($this->authUser)) {
38 2
            $this->lqlObject->setAuthUser($this->authUser);
39 2
        }
40
41 42
        return $this;
42
    }
43
44
    /**
45
     * 取得カラムの指定
46
     *
47
     * @param Column $column
48
     * @return \Kwkm\MkLiveStatusClient\Lql
49
     * @throw \InvalidArgumentException if the provided argument is not of type 'string'.
50
     */
51 23
    public function column(Column $column)
52
    {
53 23
        $this->lqlObject->setColumns($column->get());
54
55 23
        return $this;
56
    }
57
58
    /**
59
     * ヘッダ情報を取得するかの設定
60
     *
61
     * @param boolean $boolean
62
     * @return \Kwkm\MkLiveStatusClient\Lql
63
     * @throw \InvalidArgumentException if the provided argument is not of type 'boolean'.
64
     */
65 1
    public function headers($boolean)
66
    {
67 1
        $this->lqlObject->setHeader($boolean);
68
69 1
        return $this;
70
    }
71
72
    /**
73
     * フィルタの指定
74
     *
75
     * @param \Kwkm\MkLiveStatusClient\Filter $filter
76
     * @return \Kwkm\MkLiveStatusClient\Lql
77
     * @throw \InvalidArgumentException if the provided argument is not of type 'string'.
78
     */
79 29
    public function filter(Filter $filter)
80
    {
81 29
        $this->lqlObject->appendArrayQuery($filter->get());
82
83 29
        return $this;
84
    }
85
86
    /**
87
     * Stats の指定
88
     * @param \Kwkm\MkLiveStatusClient\Stats $stats
89
     * @return \Kwkm\MkLiveStatusClient\Lql
90
     * @throw \InvalidArgumentException if the provided argument is not of type 'string'.
91
     */
92 11
    public function stats(Stats $stats)
93
    {
94 11
        $this->lqlObject->appendArrayQuery($stats->get());
95
96 11
        return $this;
97
    }
98
99
    /**
100
     * パラメータの指定
101
     * @param string $parameter
102
     * @return \Kwkm\MkLiveStatusClient\Lql
103
     * @throw \InvalidArgumentException if the provided argument is not of type 'string'.
104
     */
105 1
    public function parameter($parameter)
106
    {
107 1
        $this->lqlObject->appendParameter($parameter);
108
109 1
        return $this;
110
    }
111
112
    /**
113
     * OutputFormat の指定
114
     * @param string $outputFormat
115
     * @return \Kwkm\MkLiveStatusClient\Lql
116
     * @throw \InvalidArgumentException if the provided argument is not of type 'string'.
117
     */
118 1
    public function outputFormat($outputFormat)
119
    {
120 1
        $this->lqlObject->setOutputFormat($outputFormat);
121
122 1
        return $this;
123
    }
124
125
    /**
126
     * Limit の指定
127
     * @param integer $limit
128
     * @return \Kwkm\MkLiveStatusClient\Lql
129
     * @throw \InvalidArgumentException if the provided argument is not of type 'integer'.
130
     */
131 1
    public function limit($limit)
132
    {
133 1
        $this->lqlObject->setLimit($limit);
134
135 1
        return $this;
136
    }
137
138
    /**
139
     * Lqlの実行テキストの作成
140
     * @return string
141
     */
142 40
    public function build()
143
    {
144 40
        return $this->lqlObject->build();
145
    }
146
147
    /**
148
     * コンストラクタ
149
     */
150 42
    public function __construct($table, $authUser = null)
151
    {
152 42
        $this->table = $table;
153 42
        $this->authUser = $authUser;
154 42
        $this->reset();
155 42
    }
156
}
157