helpers.php ➔ sqlOrArray()   B
last analyzed

Complexity

Conditions 5
Paths 10

Size

Total Lines 17
Code Lines 11

Duplication

Lines 17
Ratio 100 %

Importance

Changes 0
Metric Value
cc 5
eloc 11
nc 10
nop 1
dl 17
loc 17
rs 8.8571
c 0
b 0
f 0
1
<?php
2
3
use Gnf\db\Helper\GnfSqlAdd;
4
use Gnf\db\Helper\GnfSqlAnd;
5
use Gnf\db\Helper\GnfSqlBetween;
6
use Gnf\db\Helper\GnfSqlColumn;
7
use Gnf\db\Helper\GnfSqlGreater;
8
use Gnf\db\Helper\GnfSqlGreaterEqual;
9
use Gnf\db\Helper\GnfSqlJoin;
10
use Gnf\db\Helper\GnfSqlLesser;
11
use Gnf\db\Helper\GnfSqlLesserEqual;
12
use Gnf\db\Helper\GnfSqlLike;
13
use Gnf\db\Helper\GnfSqlLikeBegin;
14
use Gnf\db\Helper\GnfSqlLimit;
15
use Gnf\db\Helper\GnfSqlNot;
16
use Gnf\db\Helper\GnfSqlNow;
17
use Gnf\db\Helper\GnfSqlNull;
18
use Gnf\db\Helper\GnfSqlOr;
19
use Gnf\db\Helper\GnfSqlPassword;
20
use Gnf\db\Helper\GnfSqlRange;
21
use Gnf\db\Helper\GnfSqlRaw;
22
use Gnf\db\Helper\GnfSqlStrcat;
23
use Gnf\db\Helper\GnfSqlTable;
24
use Gnf\db\Helper\GnfSqlWhere;
25
26
if (!function_exists('sqlAdd')) {
27
	function sqlAdd($in)
28
	{
29
		return new GnfSqlAdd($in);
30
	}
31
}
32
33
if (!function_exists('sqlStrcat')) {
34
	function sqlStrcat($in)
35
	{
36
		return new GnfSqlStrcat($in);
37
	}
38
}
39
if (!function_exists('sqlPassword')) {
40
	function sqlPassword($in)
41
	{
42
		return new GnfSqlPassword($in);
43
	}
44
}
45 View Code Duplication
if (!function_exists('sqlLike')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
46
	function sqlLike($in)
47
	{
48
		//__sqlNot을 포함관계에서 최상단으로
49
		if (is_a($in, '\Gnf\db\Helper\GnfSqlNot') && is_a($in->dat, '\Gnf\db\Helper\GnfSqlCompareOperator')) {
50
			$wrapper = new GnfSqlLike($in->dat);
51
52
			return new GnfSqlNot($wrapper);
53
		}
54
55
		return new GnfSqlLike($in);
56
	}
57
58
}
59 View Code Duplication
if (!function_exists('sqlLikeBegin')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
60
	function sqlLikeBegin($in)
61
	{
62
		//__sqlNot을 포함관계에서 최상단으로
63
		if (is_a($in, '\Gnf\db\Helper\GnfSqlNot') && is_a($in->dat, '\Gnf\db\Helper\GnfSqlCompareOperator')) {
64
			$wrapper = new GnfSqlLikeBegin($in->dat);
65
66
			return new GnfSqlNot($wrapper);
67
		}
68
69
		return new GnfSqlLikeBegin($in);
70
	}
71
}
72
if (!function_exists('sqlRaw')) {
73
	function sqlRaw($in)
74
	{
75
		return new GnfSqlRaw($in);
76
	}
77
78
}
79
if (!function_exists('sqlTable')) {
80
	function sqlTable($in)
81
	{
82
		if (is_a($in, '\Gnf\db\Helper\GnfSqlTable')) {
83
			return $in;
84
		}
85
86
		return new GnfSqlTable($in);
87
	}
88
}
89
if (!function_exists('sqlColumn')) {
90
	function sqlColumn($in)
91
	{
92
		if (is_a($in, '\Gnf\db\Helper\GnfSqlColumn')) {
93
			return $in;
94
		}
95
96
		return new GnfSqlColumn($in);
97
	}
98
}
99 View Code Duplication
if (!function_exists('sqlJoin')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
100
	function sqlJoin($in, $type = 'join')
101
	{
102
		if (!is_array($in)) {
103
			$in = func_get_args();
104
		}
105
106
		return new GnfSqlJoin($in, $type);
107
	}
108
}
109 View Code Duplication
if (!function_exists('sqlLeftJoin')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
110
	function sqlLeftJoin($in)
111
	{
112
		if (!is_array($in)) {
113
			$in = func_get_args();
114
		}
115
116
		return new GnfSqlJoin($in, 'left join');
117
	}
118
}
119 View Code Duplication
if (!function_exists('sqlInnerJoin')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
120
	function sqlInnerJoin($in)
121
	{
122
		if (!is_array($in)) {
123
			$in = func_get_args();
124
		}
125
126
		return new GnfSqlJoin($in, 'inner join');
127
	}
128
}
129
if (!function_exists('sqlWhere')) {
130
	function sqlWhere(array $in)
131
	{
132
		return new GnfSqlWhere($in);
133
	}
134
}
135 View Code Duplication
if (!function_exists('sqlAnd')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
136
	function sqlAnd()
137
	{
138
		$input = func_get_args();
139
		$has_scalar_only = true;
140
		foreach ($input as $v) {
141
			$is_could_treat_as_scalar = (is_scalar($v) || $v instanceof GnfSqlNot);
142
			if (!($is_could_treat_as_scalar)) {
143
				$has_scalar_only = false;
144
				break;
145
			}
146
		}
147
		if ($has_scalar_only) {
148
			return $input;
149
		}
150
151
		return new GnfSqlAnd($input);
152
	}
153
}
154 View Code Duplication
if (!function_exists('sqlAndArray')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
155
	function sqlAndArray(array $args)
156
	{
157
		$input = $args;
158
		$has_scalar_only = true;
159
		foreach ($input as $v) {
160
			$is_could_treat_as_scalar = (is_scalar($v) || $v instanceof GnfSqlNot);
161
			if (!($is_could_treat_as_scalar)) {
162
				$has_scalar_only = false;
163
				break;
164
			}
165
		}
166
		if ($has_scalar_only) {
167
			return $input;
168
		}
169
170
		return new GnfSqlAnd($args);
171
	}
172
}
173 View Code Duplication
if (!function_exists('sqlOr')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
174
	function sqlOr()
175
	{
176
		$input = func_get_args();
177
		$has_scalar_only = true;
178
		foreach ($input as $v) {
179
			$is_could_treat_as_scalar = (is_scalar($v) || $v instanceof GnfSqlNot);
180
			if (!($is_could_treat_as_scalar)) {
181
				$has_scalar_only = false;
182
				break;
183
			}
184
		}
185
		if ($has_scalar_only) {
186
			return $input;
187
		}
188
189
		return new GnfSqlOr($input);
190
	}
191
}
192 View Code Duplication
if (!function_exists('sqlOrArray')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
193
	function sqlOrArray(array $args)
194
	{
195
		$input = $args;
196
		$has_scalar_only = true;
197
		foreach ($input as $v) {
198
			$is_could_treat_as_scalar = (is_scalar($v) || $v instanceof GnfSqlNot);
199
			if (!($is_could_treat_as_scalar)) {
200
				$has_scalar_only = false;
201
				break;
202
			}
203
		}
204
		if ($has_scalar_only) {
205
			return $input;
206
		}
207
208
		return new GnfSqlOr($args);
209
	}
210
}
211
if (!function_exists('sqlNot')) {
212
	function sqlNot($in)
213
	{
214
		//부정의 부정은 긍정
215
		if (GnfSqlNot::isSwitchable($in)) {
216
			return $in->dat;
217
		}
218
219
		return new GnfSqlNot($in);
220
	}
221
}
222 View Code Duplication
if (!function_exists('sqlGreaterEqual')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
223
	function sqlGreaterEqual($in)
224
	{
225
		//__sqlNot을 포함관계에서 최상단으로
226
		if (GnfSqlNot::isSwitchable($in)) {
227
			$wrapper = new GnfSqlGreaterEqual($in->dat);
228
229
			return new GnfSqlNot($wrapper);
230
		}
231
232
		return new GnfSqlGreaterEqual($in);
233
	}
234
}
235 View Code Duplication
if (!function_exists('sqlGreater')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
236
	function sqlGreater($in)
237
	{
238
		//__sqlNot을 포함관계에서 최상단으로
239
		if (GnfSqlNot::isSwitchable($in)) {
240
			$wrapper = new GnfSqlGreater($in->dat);
241
242
			return new GnfSqlNot($wrapper);
243
		}
244
245
		return new GnfSqlGreater($in);
246
	}
247
}
248 View Code Duplication
if (!function_exists('sqlLesserEqual')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
249
	function sqlLesserEqual($in)
250
	{
251
		//__sqlNot을 포함관계에서 최상단으로
252
		if (GnfSqlNot::isSwitchable($in)) {
253
			$wrapper = new GnfSqlLesserEqual($in->dat);
254
255
			return new GnfSqlNot($wrapper);
256
		}
257
258
		return new GnfSqlLesserEqual($in);
259
	}
260
261
}
262
if (!function_exists('sqlLesser')) {
263
	function sqlLesser($in)
264
	{
265
		//__sqlNot을 포함관계에서 최상단으로
266
		if (GnfSqlNot::isSwitchable($in)) {
267
			$wrapper = new GnfSqlLike($in->dat);
268
269
			return new GnfSqlNot($wrapper);
270
		}
271
272
		return new GnfSqlLesser($in);
273
	}
274
}
275
if (!function_exists('sqlBetween')) {
276
	function sqlBetween($in, $in2)
277
	{
278
		return new GnfSqlBetween($in, $in2);
279
	}
280
}
281
if (!function_exists('sqlRange')) {
282
	function sqlRange($in, $in2)
283
	{
284
		return new GnfSqlRange($in, $in2);
285
	}
286
}
287
if (!function_exists('sqlLimit')) {
288
	function sqlLimit()
289
	{
290
		$in = func_get_args();
291
		if (count($in) == 1) {
292
			return new GnfSqlLimit(0, $in[0]);
293
		}
294
295
		return new GnfSqlLimit($in[0], $in[1]);
296
	}
297
}
298
if (!function_exists('sqlNow')) {
299
	function sqlNow()
300
	{
301
		return new GnfSqlNow();
302
	}
303
}
304
if (!function_exists('sqlNull')) {
305
	function sqlNull()
306
	{
307
		return new GnfSqlNull();
308
	}
309
}
310