Passed
Push — develop ( 44d21a...7d51f9 )
by Neill
34:25 queued 18:25
created
neon/core/helpers.php 2 patches
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 use \Carbon\Carbon;
18 18
 use neon\core\helpers\Url;
19 19
 
20
-if (! function_exists('dp')) {
20
+if (!function_exists('dp')) {
21 21
 	/**
22 22
 	 * Debug function. Prints all passed in arguments to the screen.
23 23
 	 * arguments containing objects or arrays are output using print_r
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	}
40 40
 }
41 41
 
42
-if (! function_exists('backtrace_line_by_function')) {
42
+if (!function_exists('backtrace_line_by_function')) {
43 43
 	/**
44 44
 	 * Tries to get the line and file that called the specified functions
45 45
 	 * - will return the earliest match in execution order that it found.
@@ -51,9 +51,9 @@  discard block
 block discarded – undo
51 51
 	{
52 52
 		$bt = debug_backtrace();
53 53
 		$lineInfo = '';
54
-		foreach($bt as $trace) {
54
+		foreach ($bt as $trace) {
55 55
 			if (isset($trace['function']) && $trace['function'] === $functionToShow) {
56
-				$lineInfo = '==> [' . (isset($trace['file']) ? $trace['file'] : ' unknown file '). ':' . (isset($trace['line']) ? $trace['line'] : ' unknown line ' ) . ']';
56
+				$lineInfo = '==> ['.(isset($trace['file']) ? $trace['file'] : ' unknown file ').':'.(isset($trace['line']) ? $trace['line'] : ' unknown line ').']';
57 57
 				break;
58 58
 			}
59 59
 		}
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 	}
62 62
 }
63 63
 
64
-if (! function_exists('dp_string')) {
64
+if (!function_exists('dp_string')) {
65 65
 	/**
66 66
 	 * This generates a nice debug string and returns it. It will only
67 67
 	 * print to the screen if you are in debug mode. Otherwise it prints
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 	}
94 94
 }
95 95
 
96
-if (! function_exists('dd')) {
96
+if (!function_exists('dd')) {
97 97
 	/**
98 98
 	 * This is the same as the dp (debug print) function but exits after
99 99
 	 * **Note:** If not in debug will print to log error and not exit
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 	}
114 114
 }
115 115
 
116
-if (! function_exists('debug_message')) {
116
+if (!function_exists('debug_message')) {
117 117
 	/**
118 118
 	 * This is the same as the dp_string (debug print) function however it returns the string
119 119
 	 * The main difference is that it will only output a message if neon is in debug mode
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 }
133 133
 
134 134
 
135
-if (! function_exists('neon')) {
135
+if (!function_exists('neon')) {
136 136
 	/**
137 137
 	 * Shortcut method to ```\Neon::$app```
138 138
 	 * @param string $name
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 	}
145 145
 }
146 146
 
147
-if (! function_exists('setting')) {
147
+if (!function_exists('setting')) {
148 148
 	/**
149 149
 	 * Get a setting value
150 150
 	 *
@@ -155,13 +155,13 @@  discard block
 block discarded – undo
155 155
 	 * the setting has been set in the current session
156 156
 	 * @return string
157 157
 	 */
158
-	function setting($app, $name, $default=null, $refresh=false)
158
+	function setting($app, $name, $default = null, $refresh = false)
159 159
 	{
160 160
 		return neon()->getSettingsManager()->get($app, $name, $default, $refresh);
161 161
 	}
162 162
 }
163 163
 
164
-if (! function_exists('set_setting')) {
164
+if (!function_exists('set_setting')) {
165 165
 	/**
166 166
 	 * @param string $app the app responsible for this setting
167 167
 	 * @param string $name the setting name
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 	}
175 175
 }
176 176
 
177
-if (! function_exists('url')) {
177
+if (!function_exists('url')) {
178 178
 	/**
179 179
 	 * Alias of \neon\core\helpers\Url::to
180 180
 	 * @see \neon\core\helpers\Url::to()
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 	}
198 198
 }
199 199
 
200
-if (! function_exists('url_base')) {
200
+if (!function_exists('url_base')) {
201 201
 	/**
202 202
 	 * Returns the base URL of the current request.
203 203
 	 * @param boolean|string $scheme the URI scheme to use in the returned base URL:
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
 	}
214 214
 }
215 215
 
216
-if (! function_exists('to_bytes')) {
216
+if (!function_exists('to_bytes')) {
217 217
 	/**
218 218
 	 * Returns the number of bytes as integer from a strings like `128K` | `128M` | `2G` | `1T` | `1P`
219 219
 	 *
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 	}
226 226
 }
227 227
 
228
-if (! function_exists('format_bytes')) {
228
+if (!function_exists('format_bytes')) {
229 229
 	/**
230 230
 	 * Output a formatted size like '128M' from bytes.
231 231
 	 *
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 	}
239 239
 }
240 240
 
241
-if (! function_exists('truthy')) {
241
+if (!function_exists('truthy')) {
242 242
 	/**
243 243
 	 * Php if statement handles truthy and falsey string conversions by default e.g. evaluating a '0' string to false
244 244
 	 * however a string of 'false' is evaluated as true. This function resolves that difference. This should be used
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 	}
255 255
 }
256 256
 
257
-if (! function_exists('env')) {
257
+if (!function_exists('env')) {
258 258
 	/**
259 259
 	 * Gets the value of an environment variable.
260 260
 	 * Interprets 'true', 'false', 'empty' and 'null' strings appropriately
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 	}
290 290
 }
291 291
 
292
-if (! function_exists('neon_secret')) {
292
+if (!function_exists('neon_secret')) {
293 293
 	/**
294 294
 	 * Gets the value of NEON_SECRET creating it if missing
295 295
 	 * @return string
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 	}
300 300
 }
301 301
 
302
-if (! function_exists('neon_encryption_key')) {
302
+if (!function_exists('neon_encryption_key')) {
303 303
 	/**
304 304
 	 * Gets the value of NEON_SECRET creating it if missing
305 305
 	 * @return string
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 	}
310 310
 }
311 311
 
312
-if (! function_exists('value')) {
312
+if (!function_exists('value')) {
313 313
 	/**
314 314
 	 * Return the value of the given value.
315 315
 	 * If the $value is a Closure, it will first be executed then its result returned
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
 	}
324 324
 }
325 325
 
326
-if (! function_exists('collect')) {
326
+if (!function_exists('collect')) {
327 327
 	/**
328 328
 	 * Create a collection from the given value.
329 329
 	 *
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 	}
337 337
 }
338 338
 
339
-if (! function_exists('now')) {
339
+if (!function_exists('now')) {
340 340
 	/**
341 341
 	 * Create a new Carbon instance for the current time.
342 342
 	 *
@@ -349,27 +349,27 @@  discard block
 block discarded – undo
349 349
 	}
350 350
 }
351 351
 
352
-if (! function_exists('profile_begin')) {
352
+if (!function_exists('profile_begin')) {
353 353
 	/**
354 354
 	 * @param string $name
355 355
 	 */
356
-	function profile_begin($name, $category='neon')
356
+	function profile_begin($name, $category = 'neon')
357 357
 	{
358 358
 		\Neon::beginProfile($name, $category);
359 359
 	}
360 360
 }
361 361
 
362
-if (! function_exists('profile_end')) {
362
+if (!function_exists('profile_end')) {
363 363
 	/**
364 364
 	 * @param string $name
365 365
 	 */
366
-	function profile_end($name=null, $category='neon')
366
+	function profile_end($name = null, $category = 'neon')
367 367
 	{
368 368
 		\Neon::endProfile($name, $category);
369 369
 	}
370 370
 }
371 371
 
372
-if (! function_exists('encrypt')) {
372
+if (!function_exists('encrypt')) {
373 373
 	/**
374 374
 	 * @param string $data
375 375
 	 * @return string - encrypted data
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
 	}
381 381
 }
382 382
 
383
-if (! function_exists('decrypt')) {
383
+if (!function_exists('decrypt')) {
384 384
 	/**
385 385
 	 * @param string $data
386 386
 	 * @return string - encrypted data
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
 	}
392 392
 }
393 393
 
394
-if (! function_exists('get_alias')) {
394
+if (!function_exists('get_alias')) {
395 395
 	/**
396 396
 	 * @param string $path
397 397
 	 * @return string - resolved path
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
 	}
403 403
 }
404 404
 
405
-if (! function_exists('on_url')) {
405
+if (!function_exists('on_url')) {
406 406
 	/**
407 407
 	 * This function is useful for checking if links should be active,
408 408
 	 *
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
 		return \neon\core\helpers\Url::isUrl(...$urls);
423 423
 	}
424 424
 }
425
-if (! function_exists('_t')) {
425
+if (!function_exists('_t')) {
426 426
 	/**
427 427
 	 * Translates a message to the target language
428 428
 	 * This function is a wrapper to the \Neon::t method
@@ -442,12 +442,12 @@  discard block
 block discarded – undo
442 442
 	 * @param string $category  if provided will save the text to that category. Defaults to 'neon'
443 443
 	 * @return string the translated message.
444 444
 	 */
445
-	function _t($text, $params=[], $category='neon')
445
+	function _t($text, $params = [], $category = 'neon')
446 446
 	{
447 447
 		return \Neon::t($category, $text, $params);
448 448
 	}
449 449
 }
450
-if (! function_exists('faker')) {
450
+if (!function_exists('faker')) {
451 451
 	/**
452 452
 	 * Generate a faker object
453 453
 	 * @return \Faker\Generator;
@@ -460,7 +460,7 @@  discard block
 block discarded – undo
460 460
 		return $faker;
461 461
 	}
462 462
 }
463
-if (! function_exists('user_is')) {
463
+if (!function_exists('user_is')) {
464 464
 	/**
465 465
 	 * @return boolean whether the user is/has a particular role
466 466
 	 */
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
 	}
471 471
 }
472 472
 
473
-if (! function_exists('user_can')) {
473
+if (!function_exists('user_can')) {
474 474
 	/**
475 475
 	 * Whether the user can perform a permission
476 476
 	 * @param $permission
@@ -481,18 +481,18 @@  discard block
 block discarded – undo
481 481
 		return neon()->user->can($permission);
482 482
 	}
483 483
 }
484
-if (! function_exists('uuid')) {
484
+if (!function_exists('uuid')) {
485 485
 	/**
486 486
 	 * Generate a universally unique id
487 487
 	 * @param string $separator - default '-'
488 488
 	 * @return bool
489 489
 	 */
490
-	function uuid($separator='-')
490
+	function uuid($separator = '-')
491 491
 	{
492 492
 		return \neon\core\helpers\Hash::uuid($separator);
493 493
 	}
494 494
 }
495
-if (! function_exists('uuid64')) {
495
+if (!function_exists('uuid64')) {
496 496
 	/**
497 497
 	 * Generate a universally unique id in base64
498 498
 	 * @return bool
@@ -502,7 +502,7 @@  discard block
 block discarded – undo
502 502
 		return \neon\core\helpers\Hash::uuid64();
503 503
 	}
504 504
 }
505
-if (! function_exists('id')) {
505
+if (!function_exists('id')) {
506 506
 	/**
507 507
 	 * Whether the user can perform a permission
508 508
 	 * @return bool
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
 		return \neon\core\helpers\Hash::id();
513 513
 	}
514 514
 }
515
-if (! function_exists('is_route')) {
515
+if (!function_exists('is_route')) {
516 516
 	/**
517 517
 	 * Test whether the current application is on a particular route
518 518
 	 * This is url rewrite safe! However you must reference the module/controller/action and not the url directly
@@ -523,12 +523,12 @@  discard block
 block discarded – undo
523 523
 	 * @param array $params
524 524
 	 * @return boolean - whether on the route
525 525
 	 */
526
-	function is_route($pattern, $params=[])
526
+	function is_route($pattern, $params = [])
527 527
 	{
528 528
 		return neon()->request->isRoute($pattern, $params);
529 529
 	}
530 530
 }
531
-if (! function_exists('abort')) {
531
+if (!function_exists('abort')) {
532 532
 	/**
533 533
 	 * Throw a HttpException with the given data.
534 534
 	 *
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
 	}
545 545
 }
546 546
 
547
-if (! function_exists('abort_if')) {
547
+if (!function_exists('abort_if')) {
548 548
 	/**
549 549
 	 * Throw a HttpException with the given data if the given condition is true.
550 550
 	 *
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
 		}
563 563
 	}
564 564
 }
565
-if (! function_exists('request')) {
565
+if (!function_exists('request')) {
566 566
 	/**
567 567
 	 * Get an instance of the current request or an input item from the request.
568 568
 	 *
@@ -581,7 +581,7 @@  discard block
 block discarded – undo
581 581
 		return is_null($value) ? value($default) : $value;
582 582
 	}
583 583
 }
584
-if (! function_exists('object_get')) {
584
+if (!function_exists('object_get')) {
585 585
 	/**
586 586
 	 * Get an item from an object using "dot" notation.
587 587
 	 *
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
 		}
598 598
 
599 599
 		foreach (explode('.', $key) as $segment) {
600
-			if (! is_object($object) || ! isset($object->{$segment})) {
600
+			if (!is_object($object) || !isset($object->{$segment})) {
601 601
 				return value($default);
602 602
 			}
603 603
 
Please login to merge, or discard this patch.
Braces   +20 added lines, -14 removed lines patch added patch discarded remove patch
@@ -32,10 +32,11 @@  discard block
 block discarded – undo
32 32
 	{
33 33
 		echo dp_string(...$dump);
34 34
 		$backtrace = backtrace_line_by_function('dp');
35
-		if (neon()->debug)
36
-			echo $backtrace;
37
-		else
38
-			\Neon::error($backtrace);
35
+		if (neon()->debug) {
36
+					echo $backtrace;
37
+		} else {
38
+					\Neon::error($backtrace);
39
+		}
39 40
 	}
40 41
 }
41 42
 
@@ -86,8 +87,9 @@  discard block
 block discarded – undo
86 87
 			$str .= "<pre>$debug</pre>";
87 88
 		}
88 89
 
89
-		if (neon()->debug)
90
-			return $str;
90
+		if (neon()->debug) {
91
+					return $str;
92
+		}
91 93
 		\Neon::error($str);
92 94
 		return '';
93 95
 	}
@@ -125,8 +127,9 @@  discard block
 block discarded – undo
125 127
 	function debug_message(...$dump)
126 128
 	{
127 129
 		// security feature to ensure debug is not displayed unless in debug mode
128
-		if (!neon()->debug)
129
-			return '';
130
+		if (!neon()->debug) {
131
+					return '';
132
+		}
130 133
 		return dp_string(...$dump);
131 134
 	}
132 135
 }
@@ -190,8 +193,9 @@  discard block
 block discarded – undo
190 193
 	 */
191 194
 	function url($url = '', $absolute = false)
192 195
 	{
193
-		if ($url === null)
194
-			return '';
196
+		if ($url === null) {
197
+					return '';
198
+		}
195 199
 		$url = is_string($url) ? "/$url" : $url;
196 200
 		return Url::toRoute($url, $absolute);
197 201
 	}
@@ -248,8 +252,9 @@  discard block
 block discarded – undo
248 252
 	 */
249 253
 	function truthy($value)
250 254
 	{
251
-		if ($value && strtolower($value) !== "false")
252
-			return true;
255
+		if ($value && strtolower($value) !== "false") {
256
+					return true;
257
+		}
253 258
 		return false;
254 259
 	}
255 260
 }
@@ -455,8 +460,9 @@  discard block
 block discarded – undo
455 460
 	function faker()
456 461
 	{
457 462
 		static $faker = null;
458
-		if ($faker === null)
459
-			$faker = \Faker\Factory::create();
463
+		if ($faker === null) {
464
+					$faker = \Faker\Factory::create();
465
+		}
460 466
 		return $faker;
461 467
 	}
462 468
 }
Please login to merge, or discard this patch.
neon/core/helpers/Hash.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -26,10 +26,10 @@  discard block
 block discarded – undo
26 26
 	 * @param  string  $separator the section separator for the uuid - normally '-'
27 27
 	 * @return string
28 28
 	 */
29
-	public static function uuid($separator='-')
29
+	public static function uuid($separator = '-')
30 30
 	{
31
-		$sha = sha1(uniqid('', true).rand(1000000,9999999));
32
-		return substr($sha,0,8).$separator.substr($sha,9,4).$separator.'3'.substr($sha,15,3).$separator.'8'.substr($sha,19,3).$separator.substr($sha,22,12);
31
+		$sha = sha1(uniqid('', true).rand(1000000, 9999999));
32
+		return substr($sha, 0, 8).$separator.substr($sha, 9, 4).$separator.'3'.substr($sha, 15, 3).$separator.'8'.substr($sha, 19, 3).$separator.substr($sha, 22, 12);
33 33
 	}
34 34
 
35 35
 	/**
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	 * @param string encoding - characters used for the encoding
38 38
 	 * @return string
39 39
 	 */
40
-	public static function uuid64($encoding='0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-')
40
+	public static function uuid64($encoding = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-')
41 41
 	{
42 42
 		$uuid = self::uuid(''); // create a uuid without any '-' in it
43 43
 		return self::uuid2uuid64($uuid, $encoding);
@@ -59,13 +59,13 @@  discard block
 block discarded – undo
59 59
 	 * @param string encoding - characters used for the encoding
60 60
 	 * @return string
61 61
 	 */
62
-	public static function uuid2uuid64($uuid, $encoding='0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-')
62
+	public static function uuid2uuid64($uuid, $encoding = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-')
63 63
 	{
64
-		if (strlen($uuid)==22)
64
+		if (strlen($uuid) == 22)
65 65
 			return $uuid;
66 66
 
67 67
 		// remove any hyphens
68
-		$uuid = str_replace('-','',$uuid);
68
+		$uuid = str_replace('-', '', $uuid);
69 69
 
70 70
 		$uuid .= '0'; // 33 hexadecimal characters = 22 64-cimal chars.
71 71
 		// to convert from base-16 to base-64 (not Base64)
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 		while ($position < 33) {
76 76
 			$snip = substr($uuid, $position, 3);
77 77
 			$number = hexdec($snip);
78
-			$uuid64 .= $encoding[(integer)floor($number/64)].$encoding[(integer)($number%64)];
78
+			$uuid64 .= $encoding[(integer) floor($number / 64)].$encoding[(integer) ($number % 64)];
79 79
 			$position += 3;
80 80
 		}
81 81
 		return $uuid64;
@@ -96,14 +96,14 @@  discard block
 block discarded – undo
96 96
 	 * @return string token
97 97
 	 * @throws \ReflectionException
98 98
 	 */
99
-	public static function setObjectToToken($object, $duration=86400)
99
+	public static function setObjectToToken($object, $duration = 86400)
100 100
 	{
101 101
 		// get public properties of child class
102 102
 		$data = \Neon::getObjectVars($object);
103 103
 		$data['class'] = get_class($object);
104 104
 		if (method_exists($object, 'toArray'))
105 105
 			$data = array_merge($data, $object->toArray(['objectToken']));
106
-		$token = sha1(serialize($data) . env('NEON_SECRET'));
106
+		$token = sha1(serialize($data).env('NEON_SECRET'));
107 107
 		neon()->cache->set($token, $data, $duration); // 24 hour
108 108
 		return neon()->security->maskToken($token);
109 109
 	}
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 	 * @throws BadRequestHttpException
117 117
 	 * @throws NotFoundHttpException
118 118
 	 */
119
-	public static function getObjectFromToken($token, $expectClass=null)
119
+	public static function getObjectFromToken($token, $expectClass = null)
120 120
 	{
121 121
 		$data = neon()->cache->get(neon()->security->unmaskToken($token));
122 122
 		if ($data === null)
Please login to merge, or discard this patch.
Braces   +15 added lines, -10 removed lines patch added patch discarded remove patch
@@ -61,8 +61,9 @@  discard block
 block discarded – undo
61 61
 	 */
62 62
 	public static function uuid2uuid64($uuid, $encoding='0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-')
63 63
 	{
64
-		if (strlen($uuid)==22)
65
-			return $uuid;
64
+		if (strlen($uuid)==22) {
65
+					return $uuid;
66
+		}
66 67
 
67 68
 		// remove any hyphens
68 69
 		$uuid = str_replace('-','',$uuid);
@@ -101,8 +102,9 @@  discard block
 block discarded – undo
101 102
 		// get public properties of child class
102 103
 		$data = \Neon::getObjectVars($object);
103 104
 		$data['class'] = get_class($object);
104
-		if (method_exists($object, 'toArray'))
105
-			$data = array_merge($data, $object->toArray(['objectToken']));
105
+		if (method_exists($object, 'toArray')) {
106
+					$data = array_merge($data, $object->toArray(['objectToken']));
107
+		}
106 108
 		$token = sha1(serialize($data) . env('NEON_SECRET'));
107 109
 		neon()->cache->set($token, $data, $duration); // 24 hour
108 110
 		return neon()->security->maskToken($token);
@@ -119,17 +121,20 @@  discard block
 block discarded – undo
119 121
 	public static function getObjectFromToken($token, $expectClass=null)
120 122
 	{
121 123
 		$data = neon()->cache->get(neon()->security->unmaskToken($token));
122
-		if ($data === null)
123
-			throw new NotFoundHttpException('Does not exist or has timed out');
124
+		if ($data === null) {
125
+					throw new NotFoundHttpException('Does not exist or has timed out');
126
+		}
124 127
 
125
-		if (!isset($data['class']) || !class_exists($data['class']))
126
-			throw new BadRequestHttpException('Not a valid class');
128
+		if (!isset($data['class']) || !class_exists($data['class'])) {
129
+					throw new BadRequestHttpException('Not a valid class');
130
+		}
127 131
 
128 132
 		// instantiate the class
129 133
 		$class = Arr::remove($data, 'class');
130 134
 		$object = new $class($data);
131
-		if ($expectClass !== null && !$object instanceof $expectClass)
132
-			throw new BadRequestHttpException('Not a valid class');
135
+		if ($expectClass !== null && !$object instanceof $expectClass) {
136
+					throw new BadRequestHttpException('Not a valid class');
137
+		}
133 138
 
134 139
 		return $object;
135 140
 	}
Please login to merge, or discard this patch.
neon/core/helpers/Arr.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -39,9 +39,9 @@  discard block
 block discarded – undo
39 39
 
40 40
 		foreach ($array as $key => $value) {
41 41
 			if (is_array($value) && !empty($value)) {
42
-				$results = array_merge($results, static::dot($value, $prepend . $key . '.'));
42
+				$results = array_merge($results, static::dot($value, $prepend.$key.'.'));
43 43
 			} else {
44
-				$results[$prepend . $key] = $value;
44
+				$results[$prepend.$key] = $value;
45 45
 			}
46 46
 		}
47 47
 
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 	 */
143 143
 	public static function flatten($array, $depth = INF)
144 144
 	{
145
-		return array_reduce($array, function ($result, $item) use ($depth) {
145
+		return array_reduce($array, function($result, $item) use ($depth) {
146 146
 			$item = $item instanceof Collection ? $item->all() : $item;
147 147
 
148 148
 			if (!is_array($item)) {
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 	{
167 167
 		$original = &$array;
168 168
 
169
-		$keys = (array)$keys;
169
+		$keys = (array) $keys;
170 170
 
171 171
 		if (count($keys) === 0) {
172 172
 			return;
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 	 * @throws \InvalidArgumentException if the property $key does not exist in the array
258 258
 	 * @return mixed
259 259
 	 */
260
-	public static function getRequired($array, $key, $message=null)
260
+	public static function getRequired($array, $key, $message = null)
261 261
 	{
262 262
 		if (!array_key_exists($key, $array)) {
263 263
 			throw new \InvalidArgumentException($message ?: "You must define a '$key' property.");
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
 	 */
403 403
 	public static function only($array, $keys)
404 404
 	{
405
-		return array_intersect_key($array, array_flip((array)$keys));
405
+		return array_intersect_key($array, array_flip((array) $keys));
406 406
 	}
407 407
 
408 408
 	/**
Please login to merge, or discard this patch.
neon/core/controllers/ErrorController.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 
33 33
 		// If we have requested json we should return the error as json
34 34
 		$acceptsJson = array_key_exists('application/json', neon()->request->getAcceptableContentTypes());
35
-		if (neon()->request->getIsAjax() || $acceptsJson ) {
35
+		if (neon()->request->getIsAjax() || $acceptsJson) {
36 36
 			return $data;
37 37
 		}
38 38
 
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 			return $this->render($errorPage, $data);
58 58
 		}
59 59
 		// Look up specific framework view file e.g `core/view/error_404.php`
60
-		$viewForError = 'error_' . $data['status'];
60
+		$viewForError = 'error_'.$data['status'];
61 61
 		if ($this->findView($viewForError)) {
62 62
 			return $this->render($viewForError, $data);
63 63
 		}
@@ -72,8 +72,8 @@  discard block
 block discarded – undo
72 72
 	 */
73 73
 	public function getCustomErrorPage($errorCode)
74 74
 	{
75
-		$themeFileOld = neon('cms')->getThemeAlias() . "/error_$errorCode.tpl";
76
-		$themeFile = neon('cms')->getThemeAlias() . "/pages/errors/$errorCode.tpl";
75
+		$themeFileOld = neon('cms')->getThemeAlias()."/error_$errorCode.tpl";
76
+		$themeFile = neon('cms')->getThemeAlias()."/pages/errors/$errorCode.tpl";
77 77
 		if ($this->findView($themeFile)) {
78 78
 			return $themeFile;
79 79
 		}
Please login to merge, or discard this patch.
neon/core/BaseApp.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 			$class = \get_class($this);
67 67
 			if (($pos = strrpos($class, '\\')) !== false) {
68 68
 				$controllers = neon()->isConsoleApp() ? 'console' : 'controllers';
69
-				$this->controllerNamespace = substr($class, 0, $pos) . '\\' . $controllers;
69
+				$this->controllerNamespace = substr($class, 0, $pos).'\\'.$controllers;
70 70
 			}
71 71
 		}
72 72
 		parent::init();
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 	 * @param boolean $refresh - default false
147 147
 	 * @return type
148 148
 	 */
149
-	public function getSetting($name, $default=null, $refresh=false)
149
+	public function getSetting($name, $default = null, $refresh = false)
150 150
 	{
151 151
 		$settingManager = neon()->settingsManager;
152 152
 		return $settingManager->get($this->id, $name, $default, $refresh);
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 	/**
187 187
 	 * @inheritdoc
188 188
 	 */
189
-	public function uninstall(){}
189
+	public function uninstall() {}
190 190
 
191 191
 	/**
192 192
 	 * Get the alias key to this module (App)
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 	 */
197 197
 	public function getClassAlias()
198 198
 	{
199
-		return '@' . rtrim(str_replace(['\\', 'App'], ['/', ''], get_called_class()), "/");
199
+		return '@'.rtrim(str_replace(['\\', 'App'], ['/', ''], get_called_class()), "/");
200 200
 	}
201 201
 
202 202
 	/**
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 	 */
234 234
 	public function getAssetsPath()
235 235
 	{
236
-		return $this->getPath() . '/assets';
236
+		return $this->getPath().'/assets';
237 237
 	}
238 238
 
239 239
 	/**
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 	 */
242 242
 	public function getDocsPath()
243 243
 	{
244
-		return $this->getPath() . '/docs';
244
+		return $this->getPath().'/docs';
245 245
 	}
246 246
 
247 247
 	/**
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
 	public function getDataMapProviders()
268 268
 	{
269 269
 		$availableMaps = [];
270
-		foreach(neon()->getAllApps() as $name => $config) {
270
+		foreach (neon()->getAllApps() as $name => $config) {
271 271
 			$app = neon($name);
272 272
 			if ($app instanceof IDataMapProvider) {
273 273
 				$maps = $app->getDataMapTypes();
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 		if ($provider === null) {
294 294
 			throw new \Exception("The map provider '$name' specified can not be found.");
295 295
 		}
296
-		if (! $provider instanceof IDataMapProvider) {
296
+		if (!$provider instanceof IDataMapProvider) {
297 297
 			throw new \Exception("The Provider '$name' must implement the 'neon\\core\\interfaces\\IDataMapProvider' interface.");
298 298
 		}
299 299
 		return $provider;
@@ -339,12 +339,12 @@  discard block
 block discarded – undo
339 339
 	 * @param string $instanceOf - a string defining a class or interface that the ckasses must implement or be
340 340
 	 * @return array
341 341
 	 */
342
-	public function getClasses($subPath='', $instanceOf=false)
342
+	public function getClasses($subPath = '', $instanceOf = false)
343 343
 	{
344 344
 		$path = $this->getPath().Str::start($subPath, '/');
345 345
 		$classes = [];
346 346
 		if (!file_exists($path)) return [];
347
-		foreach(\neon\core\helpers\File::findFiles("$path", ['only' => ['*.php']]) as $file) {
347
+		foreach (\neon\core\helpers\File::findFiles("$path", ['only' => ['*.php']]) as $file) {
348 348
 			$class = $this->getClassFromFile($file);
349 349
 			// the class is not valid then skip
350 350
 			if (!$class) continue;
Please login to merge, or discard this patch.
Braces   +17 added lines, -7 removed lines patch added patch discarded remove patch
@@ -107,8 +107,9 @@  discard block
 block discarded – undo
107 107
 	public function getMenu()
108 108
 	{
109 109
 		// if the menu has been overridden
110
-		if ($this->_menu !== null)
111
-			return $this->_menu;
110
+		if ($this->_menu !== null) {
111
+					return $this->_menu;
112
+		}
112 113
 		return $this->getDefaultMenu();
113 114
 	}
114 115
 
@@ -343,13 +344,19 @@  discard block
 block discarded – undo
343 344
 	{
344 345
 		$path = $this->getPath().Str::start($subPath, '/');
345 346
 		$classes = [];
346
-		if (!file_exists($path)) return [];
347
+		if (!file_exists($path)) {
348
+			return [];
349
+		}
347 350
 		foreach(\neon\core\helpers\File::findFiles("$path", ['only' => ['*.php']]) as $file) {
348 351
 			$class = $this->getClassFromFile($file);
349 352
 			// the class is not valid then skip
350
-			if (!$class) continue;
353
+			if (!$class) {
354
+				continue;
355
+			}
351 356
 			// if we want to check the instance of the class and the $class is NOT an $instanceOf the class then skip
352
-			if ($instanceOf && !is_a($class, $instanceOf, true)) continue;
357
+			if ($instanceOf && !is_a($class, $instanceOf, true)) {
358
+				continue;
359
+			}
353 360
 			$classes[] = $class;
354 361
 		}
355 362
 		return $classes;
@@ -365,9 +372,12 @@  discard block
 block discarded – undo
365 372
 	{
366 373
 		$alias = $this->getClassAlias();
367 374
 		$fileName = basename($file);
368
-		if (in_array($fileName, ['Yii.php', 'Neon.php'])) return false;
369
-		if (!ctype_upper($fileName[0]))
375
+		if (in_array($fileName, ['Yii.php', 'Neon.php'])) {
370 376
 			return false;
377
+		}
378
+		if (!ctype_upper($fileName[0])) {
379
+					return false;
380
+		}
371 381
 		$class = str_replace([$this->getPath(), '/', '@', '.php'], ['', '\\', '\\', ''], $alias.$file);
372 382
 		return $class;
373 383
 	}
Please login to merge, or discard this patch.
neon/core/view/SmartyRenderer.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -25,12 +25,14 @@
 block discarded – undo
25 25
 		// set up the theme directories
26 26
 		foreach ($themeHierarchy as $theme) {
27 27
 			if (isset($theme['templates'])) {
28
-				foreach ($theme['templates'] as $tplDir)
29
-					$this->smarty->addTemplateDir($tplDir);
28
+				foreach ($theme['templates'] as $tplDir) {
29
+									$this->smarty->addTemplateDir($tplDir);
30
+				}
30 31
 			}
31 32
 			if (isset($theme['plugins'])) {
32
-				foreach ($theme['plugins'] as $pluginDir)
33
-					$this->smarty->addPluginsDir($pluginDir);
33
+				foreach ($theme['plugins'] as $pluginDir) {
34
+									$this->smarty->addPluginsDir($pluginDir);
35
+				}
34 36
 			}
35 37
 		}
36 38
 	}
Please login to merge, or discard this patch.
neon/core/validators/UniqueValidator.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -107,7 +107,7 @@
 block discarded – undo
107 107
 		$prefixedConditions = [];
108 108
 		foreach ($conditions as $columnName => $columnValue) {
109 109
 			if (strpos($columnName, '(') === false) {
110
-				$columnName = preg_replace('/^' . preg_quote($alias) . '\.(.*)$/', '$1', $columnName);
110
+				$columnName = preg_replace('/^'.preg_quote($alias).'\.(.*)$/', '$1', $columnName);
111 111
 				if (strpos($columnName, '[[') === 0) {
112 112
 					$prefixedColumn = "{$alias}.{$columnName}";
113 113
 				} else {
Please login to merge, or discard this patch.
neon/core/form/fields/Time.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -55,9 +55,9 @@  discard block
 block discarded – undo
55 55
 	{
56 56
 		$bits = explode(':', $timeString);
57 57
 		return [
58
-			'hh' => Arr::get($bits,0, '00'),
59
-			'mm' => Arr::get($bits,1, '00'),
60
-			'ss' => Arr::get($bits,2, '00')
58
+			'hh' => Arr::get($bits, 0, '00'),
59
+			'mm' => Arr::get($bits, 1, '00'),
60
+			'ss' => Arr::get($bits, 2, '00')
61 61
 		];
62 62
 	}
63 63
 
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 	/**
108 108
 	 * @return string
109 109
 	 */
110
-	public function getValueDisplay($context='')
110
+	public function getValueDisplay($context = '')
111 111
 	{
112 112
 		// don't show seconds if they are not to be set
113 113
 		return neon()->formatter->asTime($this->getValue());
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 	/**
126 126
 	 * @inheritdoc
127 127
 	 */
128
-	public function processAsFilter(IQuery $query, $searchData=null)
128
+	public function processAsFilter(IQuery $query, $searchData = null)
129 129
 	{
130 130
 		$searchData = ($searchData === null) ? $this->getValue() : $searchData;
131 131
 		if (!empty($searchData)) {
Please login to merge, or discard this patch.
neon/core/form/fields/Real.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@
 block discarded – undo
56 56
 	/**
57 57
 	 * @inheritdoc
58 58
 	 */
59
-	public function getValueDisplay($context='')
59
+	public function getValueDisplay($context = '')
60 60
 	{
61 61
 		$value = $this->getValue();
62 62
 		if ($this->decimal === 0)
Please login to merge, or discard this patch.
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -36,8 +36,9 @@  discard block
 block discarded – undo
36 36
 	 */
37 37
 	public function setValue($value)
38 38
 	{
39
-		if (is_numeric($value))
40
-			return parent::setValue(round($value, $this->decimal));
39
+		if (is_numeric($value)) {
40
+					return parent::setValue(round($value, $this->decimal));
41
+		}
41 42
 		parent::setvalue(null);
42 43
 	}
43 44
 
@@ -47,8 +48,9 @@  discard block
 block discarded – undo
47 48
 	public function getValue()
48 49
 	{
49 50
 		// prevent returning 0 when casting a null value to a (real) number
50
-		if (!is_numeric($this->_value))
51
-			return null;
51
+		if (!is_numeric($this->_value)) {
52
+					return null;
53
+		}
52 54
 		// (real) has been deprecated >= PHP.4 - use float instead
53 55
 		return (float) $this->_value;
54 56
 	}
@@ -59,8 +61,9 @@  discard block
 block discarded – undo
59 61
 	public function getValueDisplay($context='')
60 62
 	{
61 63
 		$value = $this->getValue();
62
-		if ($this->decimal === 0)
63
-			return neon()->formatter->asInteger($value);
64
+		if ($this->decimal === 0) {
65
+					return neon()->formatter->asInteger($value);
66
+		}
64 67
 		return neon()->formatter->asDecimal($value, $this->decimal);
65 68
 	}
66 69
 
Please login to merge, or discard this patch.