Passed
Push — next ( 3ffdf5...140724 )
by Bas
12:29
created

NormalizesStringFunctions::normalizeFindFirst()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 23
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 15
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 14
nc 4
nop 1
dl 0
loc 23
ccs 15
cts 15
cp 1
crap 3
rs 9.7998
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace LaravelFreelancerNL\FluentAQL\Traits;
6
7
use LaravelFreelancerNL\FluentAQL\QueryBuilder;
8
9
/**
10
 * Trait hasFunctions.
11
 *
12
 * AQL Function API calls.
13
 */
14
trait NormalizesStringFunctions
15
{
16
    abstract protected function normalizeNumbers(QueryBuilder $queryBuilder);
17
18 1
    protected function normalizeConcat(QueryBuilder $queryBuilder): void
19
    {
20 1
        $this->normalizeStrings($queryBuilder);
0 ignored issues
show
Bug introduced by
The method normalizeStrings() does not exist on LaravelFreelancerNL\Flue...rmalizesStringFunctions. Did you maybe mean normalizeSubstring()? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

20
        $this->/** @scrutinizer ignore-call */ 
21
               normalizeStrings($queryBuilder);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
21 1
    }
22
23 1
    protected function normalizeConcatSeparator(QueryBuilder $queryBuilder): void
24
    {
25 1
        $this->normalizeStrings($queryBuilder);
26 1
    }
27
28 3
    protected function normalizeContains(QueryBuilder $queryBuilder): void
29
    {
30 3
        $this->parameters[0] = $queryBuilder->normalizeArgument(
0 ignored issues
show
Bug Best Practice introduced by
The property parameters does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
31 3
            $this->parameters[0],
32 3
            ['Query', 'Reference', 'Bind']
33
        );
34
35 3
        $this->parameters[1] = $queryBuilder->normalizeArgument(
36 3
            $this->parameters[1],
37 3
            ['Query', 'Reference', 'Bind']
38
        );
39
40 3
        $this->parameters[2] = $queryBuilder->normalizeArgument(
41 3
            $this->parameters[2],
42 3
            ['Boolean', 'Query', 'Reference', 'Bind']
43
        );
44 3
    }
45
46 3
    protected function normalizeFindFirst(QueryBuilder $queryBuilder): void
47
    {
48 3
        $this->parameters['text'] = $queryBuilder->normalizeArgument(
0 ignored issues
show
Bug Best Practice introduced by
The property parameters does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
49 3
            $this->parameters['text'],
50 3
            ['Query', 'Reference', 'Bind']
51
        );
52
53 3
        $this->parameters['search'] = $queryBuilder->normalizeArgument(
54 3
            $this->parameters['search'],
55 3
            ['Query', 'Reference', 'Bind']
56
        );
57
58 3
        if (isset($this->parameters['start'])) {
59 2
            $this->parameters['start'] = $queryBuilder->normalizeArgument(
60 2
                $this->parameters['start'],
61 2
                ['Number', 'Query', 'Reference', 'Bind']
62
            );
63
        }
64
65 3
        if (isset($this->parameters['end'])) {
66 1
            $this->parameters['end'] = $queryBuilder->normalizeArgument(
67 1
                $this->parameters['end'],
68 1
                ['Number', 'Query', 'Reference', 'Bind']
69
            );
70
        }
71 3
    }
72
73 3
    protected function normalizeFindLast(QueryBuilder $queryBuilder): void
74
    {
75 3
        $this->parameters['text'] = $queryBuilder->normalizeArgument(
0 ignored issues
show
Bug Best Practice introduced by
The property parameters does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
76 3
            $this->parameters['text'],
77 3
            ['Query', 'Reference', 'Bind']
78
        );
79
80 3
        $this->parameters['search'] = $queryBuilder->normalizeArgument(
81 3
            $this->parameters['search'],
82 3
            ['Query', 'Reference', 'Bind']
83
        );
84
85 3
        if (isset($this->parameters['start'])) {
86 2
            $this->parameters['start'] = $queryBuilder->normalizeArgument(
87 2
                $this->parameters['start'],
88 2
                ['Number', 'Query', 'Reference', 'Bind']
89
            );
90
        }
91
92 3
        if (isset($this->parameters['end'])) {
93 1
            $this->parameters['end'] = $queryBuilder->normalizeArgument(
94 1
                $this->parameters['end'],
95 1
                ['Number', 'Query', 'Reference', 'Bind']
96
            );
97
        }
98 3
    }
99
100 1
    protected function normalizeLevenshteinDistance(QueryBuilder $queryBuilder): void
101
    {
102 1
        $this->normalizeStrings($queryBuilder);
103 1
    }
104
105 1
    protected function normalizeLower(QueryBuilder $queryBuilder): void
106
    {
107 1
        $this->normalizeStrings($queryBuilder);
108 1
    }
109
110 2
    protected function normalizeLtrim(QueryBuilder $queryBuilder): void
111
    {
112 2
        $this->parameters['value'] = $queryBuilder->normalizeArgument(
0 ignored issues
show
Bug Best Practice introduced by
The property parameters does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
113 2
            $this->parameters['value'],
114 2
            ['Query', 'Reference', 'Bind']
115
        );
116
117 2
        $this->parameters['char'] = $queryBuilder->normalizeArgument(
118 2
            $this->parameters['char'],
119 2
            ['Query', 'Reference', 'Bind']
120
        );
121 2
    }
122
123 1
    protected function normalizeRegexMatches(QueryBuilder $queryBuilder): void
124
    {
125 1
        $this->parameters[0] = $queryBuilder->normalizeArgument(
0 ignored issues
show
Bug Best Practice introduced by
The property parameters does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
126 1
            $this->parameters[0],
127 1
            ['Query', 'Reference', 'Bind']
128
        );
129
130 1
        $this->parameters[1] = $queryBuilder->normalizeArgument(
131 1
            $this->parameters[1],
132 1
            ['Query', 'Reference', 'Bind']
133
        );
134
135 1
        $this->parameters[2] = $queryBuilder->normalizeArgument(
136 1
            $this->parameters[2],
137 1
            ['Boolean', 'Query', 'Reference', 'Bind']
138
        );
139 1
    }
140
141 1
    protected function normalizeRegexReplace(QueryBuilder $queryBuilder): void
142
    {
143 1
        $this->parameters[0] = $queryBuilder->normalizeArgument(
0 ignored issues
show
Bug Best Practice introduced by
The property parameters does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
144 1
            $this->parameters[0],
145 1
            ['Query', 'Reference', 'Bind']
146
        );
147
148 1
        $this->parameters[1] = $queryBuilder->normalizeArgument(
149 1
            $this->parameters[1],
150 1
            ['Query', 'Reference', 'Bind']
151
        );
152
153 1
        $this->parameters[2] = $queryBuilder->normalizeArgument(
154 1
            $this->parameters[2],
155 1
            ['Query', 'Reference', 'Bind']
156
        );
157
158 1
        $this->parameters[3] = $queryBuilder->normalizeArgument(
159 1
            $this->parameters[3],
160 1
            ['Boolean', 'Query', 'Reference', 'Bind']
161
        );
162 1
    }
163
164 1
    protected function normalizeRegexSplit(QueryBuilder $queryBuilder): void
165
    {
166 1
        $this->parameters['text'] = $queryBuilder->normalizeArgument(
0 ignored issues
show
Bug Best Practice introduced by
The property parameters does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
167 1
            $this->parameters['text'],
168 1
            ['Query', 'Reference', 'Bind']
169
        );
170
171 1
        $this->parameters['splitExpression'] = $queryBuilder->normalizeArgument(
172 1
            $this->parameters['splitExpression'],
173 1
            ['Query', 'Reference', 'Bind']
174
        );
175
176 1
        $this->parameters['caseInsensitive'] = $queryBuilder->normalizeArgument(
177 1
            $this->parameters['caseInsensitive'],
178 1
            ['Boolean', 'Query', 'Reference', 'Bind']
179
        );
180
181 1
        if (isset($this->parameters['limit'])) {
182 1
            $this->parameters['limit'] = $queryBuilder->normalizeArgument(
183 1
                $this->parameters['limit'],
184 1
                ['Number', 'Query', 'Reference', 'Bind']
185
            );
186
        }
187 1
    }
188
189 1
    protected function normalizeRegexTest(QueryBuilder $queryBuilder): void
190
    {
191 1
        $this->parameters[0] = $queryBuilder->normalizeArgument(
0 ignored issues
show
Bug Best Practice introduced by
The property parameters does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
192 1
            $this->parameters[0],
193 1
            ['Query', 'Reference', 'Bind']
194
        );
195
196 1
        $this->parameters[1] = $queryBuilder->normalizeArgument(
197 1
            $this->parameters[1],
198 1
            ['Query', 'Reference', 'Bind']
199
        );
200
201 1
        $this->parameters[2] = $queryBuilder->normalizeArgument(
202 1
            $this->parameters[2],
203 1
            ['Boolean', 'Query', 'Reference', 'Bind']
204
        );
205 1
    }
206
207 2
    protected function normalizeRtrim(QueryBuilder $queryBuilder): void
208
    {
209 2
        $this->parameters['value'] = $queryBuilder->normalizeArgument(
0 ignored issues
show
Bug Best Practice introduced by
The property parameters does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
210 2
            $this->parameters['value'],
211 2
            ['Query', 'Reference', 'Bind']
212
        );
213
214 2
        $this->parameters['char'] = $queryBuilder->normalizeArgument(
215 2
            $this->parameters['char'],
216 2
            ['Query', 'Reference', 'Bind']
217
        );
218 2
    }
219
220 1
    protected function normalizeSoundex(QueryBuilder $queryBuilder): void
221
    {
222 1
        $this->normalizeStrings($queryBuilder);
223 1
    }
224
225 1
    protected function normalizeSplit(QueryBuilder $queryBuilder): void
226
    {
227 1
        $this->parameters['value'] = $queryBuilder->normalizeArgument(
0 ignored issues
show
Bug Best Practice introduced by
The property parameters does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
228 1
            $this->parameters['value'],
229 1
            ['Query', 'Reference', 'Bind']
230
        );
231
232 1
        $this->parameters['separator'] = $queryBuilder->normalizeArgument(
233 1
            $this->parameters['separator'],
234 1
            ['Query', 'Reference', 'Bind']
235
        );
236
237 1
        if (isset($this->parameters['limit'])) {
238 1
            $this->parameters['limit'] = $queryBuilder->normalizeArgument(
239 1
                $this->parameters['limit'],
240 1
                ['Number', 'Query', 'Reference', 'Bind']
241
            );
242
        }
243 1
    }
244
245 1
    protected function normalizeSubstitute(QueryBuilder $queryBuilder): void
246
    {
247 1
        $this->parameters['value'] = $queryBuilder->normalizeArgument(
0 ignored issues
show
Bug Best Practice introduced by
The property parameters does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
248 1
            $this->parameters['value'],
249 1
            ['Query', 'Reference', 'Bind']
250
        );
251
252 1
        $this->parameters['search'] = $queryBuilder->normalizeArgument(
253 1
            $this->parameters['search'],
254 1
            ['List', 'Reference', 'Bind']
255
        );
256
257 1
        $this->parameters['replace'] = $queryBuilder->normalizeArgument(
258 1
            $this->parameters['replace'],
259 1
            ['List', 'Query', 'Reference', 'Bind']
260
        );
261
262 1
        $this->parameters['limit'] = $queryBuilder->normalizeArgument(
263 1
            $this->parameters['limit'],
264 1
            ['Number', 'Query', 'Reference', 'Bind']
265
        );
266 1
    }
267
268 1
    protected function normalizeSubstring(QueryBuilder $queryBuilder): void
269
    {
270 1
        $this->parameters['value'] = $queryBuilder->normalizeArgument(
0 ignored issues
show
Bug Best Practice introduced by
The property parameters does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
271 1
            $this->parameters['value'],
272 1
            ['Query', 'Reference', 'Bind']
273
        );
274
275 1
         $this->parameters['offset'] = $queryBuilder->normalizeArgument(
276 1
             $this->parameters['offset'],
277 1
             ['Number', 'Query', 'Reference', 'Bind']
278
         );
279
280 1
         $this->parameters['length'] = $queryBuilder->normalizeArgument(
281 1
             $this->parameters['length'],
282 1
             ['Number', 'Query', 'Reference', 'Bind']
283
         );
284 1
    }
285
286 1
    protected function normalizeTokens(QueryBuilder $queryBuilder): void
287
    {
288 1
        $this->normalizeStrings($queryBuilder);
289 1
    }
290
291 3
    protected function normalizeTrim(QueryBuilder $queryBuilder): void
292
    {
293 3
        $this->parameters['value'] = $queryBuilder->normalizeArgument(
0 ignored issues
show
Bug Best Practice introduced by
The property parameters does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
294 3
            $this->parameters['value'],
295 3
            ['Query', 'Reference', 'Bind']
296
        );
297
298 3
        $this->parameters['type'] = $queryBuilder->normalizeArgument(
299 3
            $this->parameters['type'],
300 3
            ['Number', 'Query', 'Reference', 'Bind']
301
        );
302 3
    }
303
304 1
    protected function normalizeUpper(QueryBuilder $queryBuilder): void
305
    {
306 1
        $this->normalizeStrings($queryBuilder);
307 1
    }
308
}
309