Completed
Push — master ( 1768c8...189bb6 )
by Matthew
03:41
created

QueryObject::getWhereIns()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Ps2alerts\Api\QueryObjects;
4
5
class QueryObject
6
{
7
    /**
8
     * @var array
9
     */
10
    protected $selects;
11
12
    /**
13
     * @var array
14
     */
15
    protected $wheres;
16
17
    /**
18
     * @var array
19
     */
20
    protected $whereIns;
21
22
    /**
23
     * @var string
24
     */
25
    protected $orderBy;
26
27
    /**
28
     * @var string
29
     */
30
    protected $orderByDirection = 'asc';
31
32
    /**
33
     * @var string
34
     */
35
    protected $dimension = 'multi';
36
37
    /**
38
     * Limit of records to bring back
39
     *
40
     * @var integer
41
     */
42
    protected $limit = null;
43
44
    /**
45
     * Place to set special workaround flags
46
     *
47
     * @var string|array
48
     */
49
    protected $flags;
50
51
    /**
52
     * Adds select statement parameters to the object
53
     * Expects a string column name, which is then looped through
54
     * in the array and added to.
55
     * e.g. $queryObject->addSelect('COUNT(ResultID) AS COUNT');
56
     *
57
     * @param string $string
0 ignored issues
show
Bug introduced by
There is no parameter named $string. 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...
58
     */
59
    public function addSelect($array)
60
    {
61
        $this->selects[] = $array;
62
    }
63
64
    /**
65
     * Gets the select statement parameters out of the object
66
     *
67
     * @return array
68
     */
69
    public function getSelects()
70
    {
71
        return $this->selects;
72
    }
73
74
    /**
75
     * Adds where statements to the object
76
     *
77
     * @param array $array
78
     */
79
    public function addWhere(array $array)
80
    {
81
        $this->wheres[] = $array;
82
    }
83
84
    /**
85
     * Pulls out the array for the where statements
86
     *
87
     * @return array
88
     */
89
    public function getWheres()
90
    {
91
        return $this->wheres;
92
    }
93
94
    /**
95
     * Adds where statements to the object
96
     *
97
     * @param array $array
98
     */
99
    public function addWhereIn(array $array)
100
    {
101
        $this->whereIns[] = $array;
102
    }
103
104
    /**
105
     * Pulls out the array for the where statements
106
     *
107
     * @return array
108
     */
109
    public function getWhereIns()
110
    {
111
        return $this->whereIns;
112
    }
113
114
    /**
115
     * Set order by column
116
     *
117
     * @param string $string [description]
118
     */
119
    public function setOrderBy($string)
120
    {
121
        if (! empty($string)) {
122
            $this->orderBy = $string;
123
        }
124
    }
125
126
    /**
127
     * Get order by column
128
     *
129
     * @return string
130
     */
131
    public function getOrderBy()
132
    {
133
        return $this->orderBy;
134
    }
135
136
    /**
137
     * Set asc or desc
138
     *
139
     * @param string $string
140
     */
141
    public function setOrderByDirection($string)
142
    {
143
        if (! empty($string)) {
144
            $this->orderByDirection = $string;
145
        }
146
    }
147
148
    /**
149
     * Gets order by direction
150
     *
151
     * @return string
152
     */
153
    public function getOrderByDirection()
154
    {
155
        return $this->orderByDirection;
156
    }
157
158
    /**
159
     * Set array dimension level
160
     *
161
     * @param string $string
162
     */
163
    public function setDimension($string)
164
    {
165
        if (! empty($string)) {
166
            $this->dimension = $string;
167
        }
168
    }
169
170
    /**
171
     * Gets array dimension level
172
     *
173
     * @return string
174
     */
175
    public function getDimension()
176
    {
177
        return $this->dimension;
178
    }
179
180
    /**
181
     * Sets the limit of records to bring back
182
     *
183
     * @param integer $limit
184
     */
185
    public function setLimit($limit)
186
    {
187
        if (! empty($limit) && is_numeric($limit)) {
188
            $this->limit = $limit;
0 ignored issues
show
Documentation Bug introduced by
It seems like $limit can also be of type double or string. However, the property $limit is declared as type integer. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
189
        }
190
    }
191
192
    /**
193
     * Gets the limit of records
194
     *
195
     * @return integer
196
     */
197
    public function getLimit()
198
    {
199
        return $this->limit;
200
    }
201
202
    /**
203
     * Allows setting of workaround flags
204
     *
205
     * @param array|string $flags
206
     */
207
    public function setFlags($flags)
208
    {
209
        if (! empty($flags)) {
210
            $this->flags = $flags;
211
        }
212
    }
213
214
    /**
215
     * Retreives workaround flags
216
     *
217
     * @return array|string
218
     */
219
    public function getFlags()
220
    {
221
        return $this->flags;
222
    }
223
}
224