Passed
Push — 2.3.0 ( ...813ccf )
by steve
17:15
created
neon/firefly/services/FileManager.php 1 patch
Braces   +15 added lines, -7 removed lines patch added patch discarded remove patch
@@ -66,7 +66,9 @@  discard block
 block discarded – undo
66 66
 		neon()->firefly->isFileObjectValid($file);
67 67
 		$stream = fopen($file->getRealPath(), 'r+');
68 68
 		$uuid = $this->save($stream, $file->getFilename(), $meta);
69
-		if (is_resource($stream)) fclose($stream);
69
+		if (is_resource($stream)) {
70
+			fclose($stream);
71
+		}
70 72
 		return $uuid;
71 73
 	}
72 74
 
@@ -246,7 +248,9 @@  discard block
 block discarded – undo
246 248
 	public function destroy($uuid)
247 249
 	{
248 250
 		$file = Model::findWithDeleted()->where(['uuid' => $uuid])->one();
249
-		if ($file === null) return false;
251
+		if ($file === null) {
252
+			return false;
253
+		}
250 254
 		return $file->destroy();
251 255
 	}
252 256
 
@@ -329,7 +333,9 @@  discard block
 block discarded – undo
329 333
 			$driver = $this->getDriveFor($uuid, $file);
330 334
 			$hash = $driver->hash($file['path']);
331 335
 			$model = $this->_get($uuid);
332
-			if (!$hash) return false;
336
+			if (!$hash) {
337
+				return false;
338
+			}
333 339
 			$model->file_hash = $hash;
334 340
 			$model->save();
335 341
 		}
@@ -393,8 +399,9 @@  discard block
 block discarded – undo
393 399
 	{
394 400
 		$model = $this->_get($uuid);
395 401
 		$model->attributes = $updates;
396
-		if (!$model->save())
397
-			throw new HttpException(400, $model->getErrors());
402
+		if (!$model->save()) {
403
+					throw new HttpException(400, $model->getErrors());
404
+		}
398 405
 		return $model->toArray();
399 406
 	}
400 407
 
@@ -408,8 +415,9 @@  discard block
 block discarded – undo
408 415
 	public function findFile($drive, $path)
409 416
 	{
410 417
 		$model = Model::find()->where(['drive' => $drive, 'path' => $path])->one();
411
-		if ($model === null)
412
-			return null;
418
+		if ($model === null) {
419
+					return null;
420
+		}
413 421
 		return $model->toArray();
414 422
 	}
415 423
 
Please login to merge, or discard this patch.
neon/core/form/fields/ImageMultiple.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -47,14 +47,14 @@
 block discarded – undo
47 47
 		];
48 48
 	}
49 49
 
50
-	public function getValueDisplay($context='')
50
+	public function getValueDisplay($context = '')
51 51
 	{
52 52
 		$json = $this->getValue();
53 53
 		if (empty($json))
54 54
 			return neon()->formatter->asJson($this->getValue());
55
-		if ($context==='grid') {
55
+		if ($context === 'grid') {
56 56
 			$out = '';
57
-			foreach($json as $image) {
57
+			foreach ($json as $image) {
58 58
 				$url = neon()->firefly->getImage($image);
59 59
 				$out .= "<img src='$url' />";
60 60
 			}
Please login to merge, or discard this patch.
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -23,10 +23,12 @@  discard block
 block discarded – undo
23 23
 
24 24
 	public function setValue($value)
25 25
 	{
26
-		if (is_array($value))
27
-			$this->_value = $value;
28
-		if (is_string($value))
29
-			$this->_value = json_decode($value);
26
+		if (is_array($value)) {
27
+					$this->_value = $value;
28
+		}
29
+		if (is_string($value)) {
30
+					$this->_value = json_decode($value);
31
+		}
30 32
 	}
31 33
 
32 34
 	public function getData()
@@ -50,8 +52,9 @@  discard block
 block discarded – undo
50 52
 	public function getValueDisplay($context='')
51 53
 	{
52 54
 		$json = $this->getValue();
53
-		if (empty($json))
54
-			return neon()->formatter->asJson($this->getValue());
55
+		if (empty($json)) {
56
+					return neon()->formatter->asJson($this->getValue());
57
+		}
55 58
 		if ($context==='grid') {
56 59
 			$out = '';
57 60
 			foreach($json as $image) {
Please login to merge, or discard this patch.
neon/core/form/fields/ChoiceMultiple.php 1 patch
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -41,8 +41,9 @@  discard block
 block discarded – undo
41 41
 	public function setValueFromDb($value)
42 42
 	{
43 43
 		$items = [];
44
-		foreach ($value as $item)
45
-			$items[] = $item['key'];
44
+		foreach ($value as $item) {
45
+					$items[] = $item['key'];
46
+		}
46 47
 		return parent::setValueFromDb($items);
47 48
 	}
48 49
 
@@ -55,10 +56,12 @@  discard block
 block discarded – undo
55 56
 	public function getSelectedItems()
56 57
 	{
57 58
 		$values = $this->getValue();
58
-		if (!is_array($values))
59
-			$values = [$values];
60
-		if ($this->create === false)
61
-			return Arr::only($this->getItems(), $values);
59
+		if (!is_array($values)) {
60
+					$values = [$values];
61
+		}
62
+		if ($this->create === false) {
63
+					return Arr::only($this->getItems(), $values);
64
+		}
62 65
 		return $values;
63 66
 	}
64 67
 
Please login to merge, or discard this patch.
neon/cms/components/Daedalus.php 1 patch
Braces   +91 added lines, -66 removed lines patch added patch discarded remove patch
@@ -209,10 +209,11 @@  discard block
 block discarded – undo
209 209
 				// $result['edit'] = $this->createEditable($data);
210 210
 			}
211 211
 		}
212
-		if ($this->renderer)
213
-			$this->renderer->assign($this->params['assign'], $result);
214
-		else
215
-			return $result;
212
+		if ($this->renderer) {
213
+					$this->renderer->assign($this->params['assign'], $result);
214
+		} else {
215
+					return $result;
216
+		}
216 217
 	}
217 218
 
218 219
 	/**
@@ -230,19 +231,22 @@  discard block
 block discarded – undo
230 231
 	protected function queryChoice($template=true)
231 232
 	{
232 233
 		// check usage
233
-		if (!isset($this->params['member']))
234
-			return "Usage: you must provide a 'member' parameter. You provided ".print_r($this->params,true);
235
-		if ($this->renderer && !isset($this->params['assign']))
236
-			return "Usage: you must provide an 'assign' parameter. You provided ".print_r($this->params,true);
237
-		if (strpos($this->params['member'],':') === false && !isset($this->params['class']))
238
-			return "Usage: if you do not scope the member as class::member then you must provide the class parameter";
234
+		if (!isset($this->params['member'])) {
235
+					return "Usage: you must provide a 'member' parameter. You provided ".print_r($this->params,true);
236
+		}
237
+		if ($this->renderer && !isset($this->params['assign'])) {
238
+					return "Usage: you must provide an 'assign' parameter. You provided ".print_r($this->params,true);
239
+		}
240
+		if (strpos($this->params['member'],':') === false && !isset($this->params['class'])) {
241
+					return "Usage: if you do not scope the member as class::member then you must provide the class parameter";
242
+		}
239 243
 
240 244
 		// extract out class and member
241 245
 		$class = null;
242 246
 		$member = null;
243
-		if (strpos($this->params['member'],':') !== false)
244
-			list ($class, $member) = explode(':', str_replace('::',':',$this->params['member']));
245
-		else {
247
+		if (strpos($this->params['member'],':') !== false) {
248
+					list ($class, $member) = explode(':', str_replace('::',':',$this->params['member']));
249
+		} else {
246 250
 			$class = $this->params['class'];
247 251
 			$member = $this->params['member'];
248 252
 		}
@@ -254,10 +258,11 @@  discard block
 block discarded – undo
254 258
 		if (!isset(self::$_choices[$key])) {
255 259
 			$dds = neon('dds')->iDdsClassManagement;
256 260
 			$result = $dds->getMember($class, $member, ['choices']);
257
-			if (!empty($result) && isset($result['choices']))
258
-				self::$_choices[$key] = $result['choices'];
259
-			else
260
-				self::$_choices[$key] = [];
261
+			if (!empty($result) && isset($result['choices'])) {
262
+							self::$_choices[$key] = $result['choices'];
263
+			} else {
264
+							self::$_choices[$key] = [];
265
+			}
261 266
 		}
262 267
 		$choices = self::$_choices[$key];
263 268
 		if (isset($this->params['order'])) {
@@ -267,10 +272,11 @@  discard block
 block discarded – undo
267 272
 				asort($choices);
268 273
 			}
269 274
 		}
270
-		if ($this->renderer)
271
-			$this->renderer->assign($this->params['assign'], $choices);
272
-		else
273
-			return $choices;
275
+		if ($this->renderer) {
276
+					$this->renderer->assign($this->params['assign'], $choices);
277
+		} else {
278
+					return $choices;
279
+		}
274 280
 	}
275 281
 
276 282
 	/**
@@ -288,11 +294,13 @@  discard block
 block discarded – undo
288 294
 	protected function queryMap()
289 295
 	{
290 296
 		// check usage
291
-		if (!isset($this->params['class']))
292
-			return "Usage: you must provide a 'class' parameter. You provided ".print_r($this->params,true);
297
+		if (!isset($this->params['class'])) {
298
+					return "Usage: you must provide a 'class' parameter. You provided ".print_r($this->params,true);
299
+		}
293 300
 
294
-		if ($this->renderer && !isset($this->params['assign']))
295
-			return "Usage: you must provide an 'assign' parameter. You provided ".print_r($this->params,true);
301
+		if ($this->renderer && !isset($this->params['assign'])) {
302
+					return "Usage: you must provide an 'assign' parameter. You provided ".print_r($this->params,true);
303
+		}
296 304
 
297 305
 		$fields = isset($this->params['fields']) ? $this->params['fields'] : [];
298 306
 
@@ -311,11 +319,13 @@  discard block
 block discarded – undo
311 319
 			self::$_maps[$class] = $result;
312 320
 		}
313 321
 		$map = self::$_maps[$class];
314
-		if (isset($this->params['flip']))
315
-			$map = array_flip($map);
322
+		if (isset($this->params['flip'])) {
323
+					$map = array_flip($map);
324
+		}
316 325
 
317
-		if ($this->renderer)
318
-			$this->renderer->assign($this->params['assign'], $map);
326
+		if ($this->renderer) {
327
+					$this->renderer->assign($this->params['assign'], $map);
328
+		}
319 329
 		return $map;
320 330
 	}
321 331
 
@@ -331,11 +341,13 @@  discard block
 block discarded – undo
331 341
 		$json = trim(str_replace("'", '"', $data));
332 342
 		if (strlen($json) > 0) {
333 343
 			// for convenience the beginning and ending brackets are optional so add if not supplied
334
-			if (strpos($json, '{') !== 0)
335
-				$json = '{'.$json.'}';
344
+			if (strpos($json, '{') !== 0) {
345
+							$json = '{'.$json.'}';
346
+			}
336 347
 			$request = json_decode($json, true);
337
-			if ($request === null)
338
-				throw new \Exception("Failing to json decode the data request: $json converted from $data. ");
348
+			if ($request === null) {
349
+							throw new \Exception("Failing to json decode the data request: $json converted from $data. ");
350
+			}
339 351
 		}
340 352
 		return $request;
341 353
 	}
@@ -360,10 +372,12 @@  discard block
 block discarded – undo
360 372
 		$dps = array_intersect_key($params, array_flip($dpa));
361 373
 		if (count($dps)) {
362 374
 			$data = [];
363
-			if ((isset($dps['dds']) || isset($dps['dds_page'])) && empty($dps['dds_class']))
364
-				$dps['dds_class'] = $params['type'];
365
-			if (isset($dps['dds_class']))
366
-				$data[] = "'class':'$dps[dds_class]'";
375
+			if ((isset($dps['dds']) || isset($dps['dds_page'])) && empty($dps['dds_class'])) {
376
+							$dps['dds_class'] = $params['type'];
377
+			}
378
+			if (isset($dps['dds_class'])) {
379
+							$data[] = "'class':'$dps[dds_class]'";
380
+			}
367 381
 
368 382
 			// create the filters
369 383
 			$filters = [];
@@ -371,9 +385,9 @@  discard block
 block discarded – undo
371 385
 			// create the page specific filter
372 386
 			if (!empty($dps['dds_page'])) {
373 387
 				$pageId = null;
374
-				if ($dps['dds_page'] === true || $dps['dds_page'] === 'true')
375
-					$pageId = neon()->cms->getPage()->getId();
376
-				else {
388
+				if ($dps['dds_page'] === true || $dps['dds_page'] === 'true') {
389
+									$pageId = neon()->cms->getPage()->getId();
390
+				} else {
377 391
 					// either a nice id or a page id
378 392
 					// $pageId = self::$page->niceId2PageId($dps['dds_page']);
379 393
 					// if (!$pageId)
@@ -381,43 +395,51 @@  discard block
 block discarded – undo
381 395
 					// object therefore has not worked for a while!
382 396
 					$pageId = $dps['dds_page'];
383 397
 				}
384
-				if ($pageId)
385
-					$filters[] = "['page_id','=','$pageId']";
398
+				if ($pageId) {
399
+									$filters[] = "['page_id','=','$pageId']";
400
+				}
386 401
 			}
387 402
 
388 403
 			// add other filters
389 404
 			if (isset($dps['dds_filter']) && !empty($dps['dds_filter'])) {
390
-				if (is_array($dps['dds_filter']))
391
-					$filters[] = json_encode($dps['dds_filter']);
405
+				if (is_array($dps['dds_filter'])) {
406
+									$filters[] = json_encode($dps['dds_filter']);
407
+				}
392 408
 				// else deprecated json approach
393
-				else if (strpos(trim($dps['dds_filter']), '[')!==0)
394
-					$filters[] = "[$dps[dds_filter]]";
395
-				else
396
-					$filters[] = $dps['dds_filter'];
409
+				else if (strpos(trim($dps['dds_filter']), '[')!==0) {
410
+									$filters[] = "[$dps[dds_filter]]";
411
+				} else {
412
+									$filters[] = $dps['dds_filter'];
413
+				}
397 414
 			}
398 415
 
399 416
 			// create the filters clause
400
-			if (count($filters))
401
-				$data[] = "'filters':".implode(',',$filters);
417
+			if (count($filters)) {
418
+							$data[] = "'filters':".implode(',',$filters);
419
+			}
402 420
 
403 421
 			// sort out the order
404 422
 			if (isset($dps['dds_order'])) {
405
-				if (is_array($dps['dds_order']))
406
-					$data[] = "'order':".json_encode($dps['dds_order']);
423
+				if (is_array($dps['dds_order'])) {
424
+									$data[] = "'order':".json_encode($dps['dds_order']);
425
+				}
407 426
 				// else deprecated json approach
408
-				else
409
-					$data[] = "'order':{".$dps['dds_order']."}";
427
+				else {
428
+									$data[] = "'order':{".$dps['dds_order']."}";
429
+				}
410 430
 			}
411 431
 
412 432
 			// sort out the limit
413 433
 			if (isset($dps['dds_limit'])) {
414
-				if (is_numeric($dps['dds_limit']))
415
-					$data[] = "'limit':{'length':$dps[dds_limit]}";
416
-				else if (is_array($dps['dds_limit']))
417
-					$data[] = "'limit':".json_encode($dps['dds_limit']);
434
+				if (is_numeric($dps['dds_limit'])) {
435
+									$data[] = "'limit':{'length':$dps[dds_limit]}";
436
+				} else if (is_array($dps['dds_limit'])) {
437
+									$data[] = "'limit':".json_encode($dps['dds_limit']);
438
+				}
418 439
 				// else deprecated json approach
419
-				else
420
-					$data[] = "'limit':{".$dps['dds_limit']."}";
440
+				else {
441
+									$data[] = "'limit':{".$dps['dds_limit']."}";
442
+				}
421 443
 			}
422 444
 			$params['data'] = '{'.implode(', ', $data).'}';
423 445
 		}
@@ -434,8 +456,9 @@  discard block
 block discarded – undo
434 456
 	protected function canonicalise($params)
435 457
 	{
436 458
 		$canon = [];
437
-		if (empty($params['assign']) && $this->renderer !== null)
438
-			throw new \InvalidArgumentException("You must set an 'assign' parameter when using the 'dds' tag");
459
+		if (empty($params['assign']) && $this->renderer !== null) {
460
+					throw new \InvalidArgumentException("You must set an 'assign' parameter when using the 'dds' tag");
461
+		}
439 462
 		foreach ($params as $k => $v) {
440 463
 			if ($k == 'assign') {
441 464
 				$canon[$k] = $v;
@@ -465,8 +488,9 @@  discard block
 block discarded – undo
465 488
 				$classType = $d['_class_type'];
466 489
 				foreach ($d as $field=>$value) {
467 490
 					// ignore all bookkeeping fields
468
-					if (strpos($field, '_')===0)
469
-						continue;
491
+					if (strpos($field, '_')===0) {
492
+											continue;
493
+					}
470 494
 					$edit[$i][$field] = self::createFieldEditable($classType, $field, $d['_uuid'], $value);
471 495
 				}
472 496
 			}
@@ -488,8 +512,9 @@  discard block
 block discarded – undo
488 512
 	 */
489 513
 	public static function createFieldEditable($classType, $field, $key, $value)
490 514
 	{
491
-		if (is_array($value))
492
-			return $value;
515
+		if (is_array($value)) {
516
+					return $value;
517
+		}
493 518
 
494 519
 		/**
495 520
 		 * This needs to be changed to generate an appropriate form to edit the
Please login to merge, or discard this patch.