Passed
Push — develop ( 319bd8...330c7a )
by Neill
16:41 queued 15s
created
neon/phoebe/services/PhoebeService.php 1 patch
Braces   +8 added lines, -6 removed lines patch added patch discarded remove patch
@@ -82,13 +82,15 @@
 block discarded – undo
82 82
 		$types = $this->listPhoebeTypes();
83 83
 		$requested = isset($types[$phoebeKey]) ? $types[$phoebeKey] : null;
84 84
 		// check that we can create the requested type
85
-		if (!($requested && in_array($requested['status'], ['AVAILABLE', 'IN_DEVELOPMENT'])))
86
-			return null;
85
+		if (!($requested && in_array($requested['status'], ['AVAILABLE', 'IN_DEVELOPMENT']))) {
86
+					return null;
87
+		}
87 88
 		$adapter = $requested['adapter'];
88
-		if (strpos($adapter, '\\') !== false)
89
-			$type = $adapter;
90
-		else
91
-			$type = str_replace('ADAPTER', $requested['adapter'], $this->genericTypePath);
89
+		if (strpos($adapter, '\\') !== false) {
90
+					$type = $adapter;
91
+		} else {
92
+					$type = str_replace('ADAPTER', $requested['adapter'], $this->genericTypePath);
93
+		}
92 94
 		return $type ? new $type : null;
93 95
 	}
94 96
 
Please login to merge, or discard this patch.
neon/phoebe/services/adapters/appforms/PhoebeObject.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -106,13 +106,13 @@  discard block
 block discarded – undo
106 106
 	 *
107 107
 	 * @param type $objects
108 108
 	 */
109
-	protected function updateDataFromDds(&$objects, $isTree=true)
109
+	protected function updateDataFromDds(&$objects, $isTree = true)
110 110
 	{
111 111
 		// It may be better to flatten the data and make a more intelligent
112 112
 		// set of selects from the database, or use the idea of requests and
113 113
 		// do this in two passes
114 114
 		$dds = neon('dds')->getIDdsObjectManagement();
115
-		foreach($objects as &$object) {
115
+		foreach ($objects as &$object) {
116 116
 			if (!empty($object['_uuid'])) {
117 117
 				// update the object definition to pick up any new fields from the definition
118 118
 				$object = array_merge($this->getAllowedFieldsForClass($object['_classType']), $object);
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 	 * @param array &$objects
192 192
 	 * @return array
193 193
 	 */
194
-	protected function extractObjects(&$objects, &$extractedObjectIds=null)
194
+	protected function extractObjects(&$objects, &$extractedObjectIds = null)
195 195
 	{
196 196
 		//
197 197
 		// TODO - this code is particularly messy - refactor
@@ -394,7 +394,7 @@  discard block
 block discarded – undo
394 394
 		if (!empty($objRend['dataSourceMap'])) {
395 395
 			foreach ($objRend['dataSourceMap'] as $member => $dsMap) {
396 396
 				$dsDef = $this->getDataSourceDefinition($dsMap['id']);
397
-				if (($dsObj = $this->getDataSourceObject($dsDef['label']))!==null) {
397
+				if (($dsObj = $this->getDataSourceObject($dsDef['label'])) !== null) {
398 398
 					$object[$member] = $dsObj[$dsMap['memberRef']];
399 399
 				}
400 400
 			}
Please login to merge, or discard this patch.
Braces   +33 added lines, -22 removed lines patch added patch discarded remove patch
@@ -41,8 +41,9 @@  discard block
 block discarded – undo
41 41
 	public function editObject($changes)
42 42
 	{
43 43
 		// check if there's anything to do
44
-		if (empty($changes) || $changes == $this->data)
45
-			return true;
44
+		if (empty($changes) || $changes == $this->data) {
45
+					return true;
46
+		}
46 47
 
47 48
 		// extract the data and save appropriately to
48 49
 		// the associated database tables ... if any
@@ -59,8 +60,9 @@  discard block
 block discarded – undo
59 60
 	public function setDataSources($sources)
60 61
 	{
61 62
 		foreach ($sources as $key=>$value) {
62
-			if (empty($value))
63
-				unset($sources[$key]);
63
+			if (empty($value)) {
64
+							unset($sources[$key]);
65
+			}
64 66
 		}
65 67
 		$this->dataSourceIds = $sources;
66 68
 	}
@@ -97,8 +99,9 @@  discard block
 block discarded – undo
97 99
 	 */
98 100
 	protected function getDataSources()
99 101
 	{
100
-		foreach ($this->dataSourceIds as $key=>$id)
101
-			$this->dataSourceObjects[$key] = $this->getDds()->getObject($id);
102
+		foreach ($this->dataSourceIds as $key=>$id) {
103
+					$this->dataSourceObjects[$key] = $this->getDds()->getObject($id);
104
+		}
102 105
 	}
103 106
 
104 107
 	/**
@@ -118,8 +121,9 @@  discard block
 block discarded – undo
118 121
 				$object = array_merge($this->getAllowedFieldsForClass($object['_classType']), $object);
119 122
 				// now update the object with the data from daedalus
120 123
 				$data = $dds->getObject($object['_uuid']);
121
-				if ($data)
122
-					$object = array_replace($object, array_intersect_key($data, $object));
124
+				if ($data) {
125
+									$object = array_replace($object, array_intersect_key($data, $object));
126
+				}
123 127
 			}
124 128
 			// recursively update if this is in a tree structure
125 129
 			if ($isTree && is_array($object)) {
@@ -179,8 +183,9 @@  discard block
 block discarded – undo
179 183
 				}
180 184
 			}
181 185
 		}
182
-		if (count($relations))
183
-			$this->saveLinkedObjects($relations);
186
+		if (count($relations)) {
187
+					$this->saveLinkedObjects($relations);
188
+		}
184 189
 	}
185 190
 
186 191
 	/**
@@ -216,8 +221,9 @@  discard block
 block discarded – undo
216 221
 							$relations = $renderables[$subRenderable]['relations'];
217 222
 							foreach ($relations as $relation) {
218 223
 								$memberRef = $relation['memberRef'];
219
-								if (!isset($extracted['__relations'][$objId][$memberRef]))
220
-									$extracted['__relations'][$objId][$memberRef] = [];
224
+								if (!isset($extracted['__relations'][$objId][$memberRef])) {
225
+																	$extracted['__relations'][$objId][$memberRef] = [];
226
+								}
221 227
 								$extracted['__relations'][$objId][$memberRef] = array_merge($extracted['__relations'][$objId][$memberRef], $newObjectIds);
222 228
 							}
223 229
 						}
@@ -259,8 +265,9 @@  discard block
 block discarded – undo
259 265
 		if (empty($fieldsForClass[$classType])) {
260 266
 			$definition = $this->getDefinition();
261 267
 			foreach ($definition['renderables'] as $r) {
262
-				if ($r['type'] == 'MemberComponent')
263
-					$fieldsForClass[$r['class_type']][$r['member_ref']] = null;
268
+				if ($r['type'] == 'MemberComponent') {
269
+									$fieldsForClass[$r['class_type']][$r['member_ref']] = null;
270
+				}
264 271
 			}
265 272
 		}
266 273
 		return $fieldsForClass[$classType];
@@ -322,8 +329,9 @@  discard block
 block discarded – undo
322 329
 			if (isset($renderables[$phoebeKey])) {
323 330
 				// check the renderable exists and is a class component
324 331
 				$ren = $renderables[$phoebeKey];
325
-				if ($ren['type'] != 'ClassComponent')
326
-					continue;
332
+				if ($ren['type'] != 'ClassComponent') {
333
+									continue;
334
+				}
327 335
 
328 336
 				// create the object and any required data params
329 337
 				$object = [
@@ -334,8 +342,9 @@  discard block
 block discarded – undo
334 342
 				foreach ($ren['items'] as $item) {
335 343
 					if (isset($renderables[$item])) {
336 344
 						$iRen = $renderables[$item];
337
-						if ($iRen['type'] != 'MemberComponent')
338
-							continue;
345
+						if ($iRen['type'] != 'MemberComponent') {
346
+													continue;
347
+						}
339 348
 						$object[$iRen['member_ref']] = null;
340 349
 					}
341 350
 				}
@@ -455,8 +464,9 @@  discard block
 block discarded – undo
455 464
 	private $_class = null;
456 465
 	private function getClass()
457 466
 	{
458
-		if (!$this->_class)
459
-			$this->_class = neon('phoebe')->getIPhoebeType($this->phoebeType)->getClass($this->classType);
467
+		if (!$this->_class) {
468
+					$this->_class = neon('phoebe')->getIPhoebeType($this->phoebeType)->getClass($this->classType);
469
+		}
460 470
 		return $this->_class;
461 471
 	}
462 472
 
@@ -469,8 +479,9 @@  discard block
 block discarded – undo
469 479
 	private $_dds = null;
470 480
 	private function getDds()
471 481
 	{
472
-		if (!$this->_dds)
473
-			$this->_dds = neon('dds')->getIDdsObjectManagement();
482
+		if (!$this->_dds) {
483
+					$this->_dds = neon('dds')->getIDdsObjectManagement();
484
+		}
474 485
 		return $this->_dds;
475 486
 	}
476 487
 
Please login to merge, or discard this patch.
neon/phoebe/services/adapters/appforms/PhoebeClass.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 	/**
24 24
 	 * @inheritdoc
25 25
 	 */
26
-	public function getClassFormDefinition(array $fields=[])
26
+	public function getClassFormDefinition(array $fields = [])
27 27
 	{
28 28
 		// if there is no definition return an empty form
29 29
 		if (empty($this->definition))
@@ -133,19 +133,19 @@  discard block
 block discarded – undo
133 133
 	protected function convertRenderablesToFields($key, $renderables) {
134 134
 		if (!isset($renderables[$key])) {
135 135
 			dd("Key $key doesn't exist in the form definition", $renderables);
136
-		throw new \RuntimeException("Key $key doesn't exist in the form definition");}
136
+		throw new \RuntimeException("Key $key doesn't exist in the form definition"); }
137 137
 		$rend = $renderables[$key];
138
-		$field=[];
138
+		$field = [];
139 139
 		if (!empty($rend['type'])) {
140 140
 			$field = [];
141
-			switch($rend['type']) {
141
+			switch ($rend['type']) {
142 142
 				case 'FormComponent':
143 143
 					if (isset($rend['items']))
144 144
 						$field['fields'] = $this->addItems($rend['items'], $renderables);
145 145
 				break;
146 146
 				case 'ClassComponent':
147 147
 					$classDefinition = isset($rend['definition']) ? $rend['definition'] : [];
148
-					if (count($rend['items'])>0) {
148
+					if (count($rend['items']) > 0) {
149 149
 						$field['fields'] = [];
150 150
 						$field['label'] = '';
151 151
 						if (isset($classDefinition['showLabel']) && $classDefinition['showLabel'])
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 		$field['allowRemove'] = $allowChangeOfRepeats;
218 218
 
219 219
 		// now set the template header part
220
-		$field['template']['class'] =  "neon\\core\\form\\Form";
220
+		$field['template']['class'] = "neon\\core\\form\\Form";
221 221
 	}
222 222
 
223 223
 	/**
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 	 * so we know what object it belongs to if set
226 226
 	 * @return array
227 227
 	 */
228
-	protected function createHiddenField($name, $value=null)
228
+	protected function createHiddenField($name, $value = null)
229 229
 	{
230 230
 		return [
231 231
 			'class' => "neon\\core\\form\\fields\\Hidden",
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 	protected function createFieldName($field)
239 239
 	{
240 240
 		$uuid = isset($field['id']) ? $field['id'] : Hash::uuid64();
241
-		return str_replace(['-','_'],['a','Z'], $uuid);
241
+		return str_replace(['-', '_'], ['a', 'Z'], $uuid);
242 242
 	}
243 243
 
244 244
 }
245 245
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +29 added lines, -20 removed lines patch added patch discarded remove patch
@@ -26,8 +26,9 @@  discard block
 block discarded – undo
26 26
 	public function getClassFormDefinition(array $fields=[])
27 27
 	{
28 28
 		// if there is no definition return an empty form
29
-		if (empty($this->definition))
30
-			return [];
29
+		if (empty($this->definition)) {
30
+					return [];
31
+		}
31 32
 
32 33
 		// TODO - NJ20180426 - see if we can get Phoebe to listen to $fields
33 34
 
@@ -55,8 +56,9 @@  discard block
 block discarded – undo
55 56
 	 */
56 57
 	public function editClass($changes)
57 58
 	{
58
-		if (isset($changes['definition']))
59
-			$changes['definition'] = $this->prepareDefinition($changes['definition']);
59
+		if (isset($changes['definition'])) {
60
+					$changes['definition'] = $this->prepareDefinition($changes['definition']);
61
+		}
60 62
 		parent::editClass($changes);
61 63
 	}
62 64
 
@@ -84,8 +86,9 @@  discard block
 block discarded – undo
84 86
 	{
85 87
 		$definition = $this->definition;
86 88
 		$applicationDataPhoebeUuids = [];
87
-		foreach ($ddsClassTypes as $ct)
88
-			$applicationDataPhoebeUuids[$ct] = null;
89
+		foreach ($ddsClassTypes as $ct) {
90
+					$applicationDataPhoebeUuids[$ct] = null;
91
+		}
89 92
 		foreach ($definition['renderables'] as $k=>$r) {
90 93
 			if ($r['type'] == 'ClassComponent' && in_array($r['class_type'], $ddsClassTypes)) {
91 94
 				$applicationDataPhoebeUuids[$r['class_type']] = $k;
@@ -125,8 +128,9 @@  discard block
 block discarded – undo
125 128
 		$fields = $this->convertRenderablesToFields($definition['rootNode'], $definition['renderables']);
126 129
 		$form['fields'] = $fields['fields'];
127 130
 		// apply any overrides to the form
128
-		if ($this->_overrides)
129
-			$form = array_replace_recursive($form, $this->_overrides);
131
+		if ($this->_overrides) {
132
+					$form = array_replace_recursive($form, $this->_overrides);
133
+		}
130 134
 		return $form;
131 135
 	}
132 136
 
@@ -140,23 +144,27 @@  discard block
 block discarded – undo
140 144
 			$field = [];
141 145
 			switch($rend['type']) {
142 146
 				case 'FormComponent':
143
-					if (isset($rend['items']))
144
-						$field['fields'] = $this->addItems($rend['items'], $renderables);
147
+					if (isset($rend['items'])) {
148
+											$field['fields'] = $this->addItems($rend['items'], $renderables);
149
+					}
145 150
 				break;
146 151
 				case 'ClassComponent':
147 152
 					$classDefinition = isset($rend['definition']) ? $rend['definition'] : [];
148 153
 					if (count($rend['items'])>0) {
149 154
 						$field['fields'] = [];
150 155
 						$field['label'] = '';
151
-						if (isset($classDefinition['showLabel']) && $classDefinition['showLabel'])
152
-							$field['label'] = isset($classDefinition['label']) ? $classDefinition['label'] : $rend['label'];
156
+						if (isset($classDefinition['showLabel']) && $classDefinition['showLabel']) {
157
+													$field['label'] = isset($classDefinition['label']) ? $classDefinition['label'] : $rend['label'];
158
+						}
153 159
 						$field['description'] = '';
154
-						if (isset($classDefinition['showDescription']) && $classDefinition['showDescription'])
155
-							$field['description'] = isset($classDefinition['description']) ? $classDefinition['description'] : $rend['description'];
160
+						if (isset($classDefinition['showDescription']) && $classDefinition['showDescription']) {
161
+													$field['description'] = isset($classDefinition['description']) ? $classDefinition['description'] : $rend['description'];
162
+						}
156 163
 						if ($this->isRepeater($rend)) {
157 164
 							$this->addRepeaterHeader($field, $rend['definition'], $key);
158
-							if (isset($classDefinition['showLabel']) && $classDefinition['showLabel'])
159
-								$field['template']['label'] = isset($classDefinition['label']) ? $classDefinition['label'] : $rend['label'];
165
+							if (isset($classDefinition['showLabel']) && $classDefinition['showLabel']) {
166
+															$field['template']['label'] = isset($classDefinition['label']) ? $classDefinition['label'] : $rend['label'];
167
+							}
160 168
 							$field['template']['fields'] = $this->addItems($rend['items'], $renderables);
161 169
 							$field['template']['fields'][] = $this->createHiddenField('_renderable', $key);
162 170
 							$field['template']['fields'][] = $this->createHiddenField('_classType', $rend['class_type']);
@@ -191,10 +199,11 @@  discard block
 block discarded – undo
191 199
 		$order = 1;
192 200
 		foreach ($items as $rKey) {
193 201
 			$subField = $this->convertRenderablesToFields($rKey, $renderables, 1);
194
-			if (isset($subField[$rKey]))
195
-				$field[$rKey] = $subField[$rKey];
196
-			else
197
-				$field[$rKey] = $subField;
202
+			if (isset($subField[$rKey])) {
203
+							$field[$rKey] = $subField[$rKey];
204
+			} else {
205
+							$field[$rKey] = $subField;
206
+			}
198 207
 			$field[$rKey]['order'] = $order++;
199 208
 		}
200 209
 		return $field;
Please login to merge, or discard this patch.
neon/phoebe/services/adapters/appforms/PhoebeType.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 {
19 19
 	use PhoebeTrait;
20 20
 
21
-	public function __construct($config=[])
21
+	public function __construct($config = [])
22 22
 	{
23 23
 		$path = '\neon\phoebe\services\adapters\appforms';
24 24
 		$config['phoebeType'] = 'applicationForm';
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 		parent::__construct($config);
29 29
 	}
30 30
 
31
-	public function getClass($classType, $version=null, $classOverrideCriteria=[])
31
+	public function getClass($classType, $version = null, $classOverrideCriteria = [])
32 32
 	{
33 33
 		$class = parent::getClass($classType, $version, $classOverrideCriteria);
34 34
 		// update member definitions with the latest from the database and
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -33,8 +33,9 @@  discard block
 block discarded – undo
33 33
 		$class = parent::getClass($classType, $version, $classOverrideCriteria);
34 34
 		// update member definitions with the latest from the database and
35 35
 		// override again with the changes that were defined before
36
-		if ($class)
37
-			$class->definition = $this->updateDefinitionFromDds($class->definition);
36
+		if ($class) {
37
+					$class->definition = $this->updateDefinitionFromDds($class->definition);
38
+		}
38 39
 		return $class;
39 40
 	}
40 41
 
@@ -55,8 +56,9 @@  discard block
 block discarded – undo
55 56
 	{
56 57
 		$object = parent::getObject($objectId);
57 58
 		// update the data from Daedalus if required
58
-		if ($object)
59
-			$object->updateFromDds();
59
+		if ($object) {
60
+					$object->updateFromDds();
61
+		}
60 62
 		return $object;
61 63
 	}
62 64
 
Please login to merge, or discard this patch.
neon/phoebe/services/adapters/appforms/PhoebeTrait.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	 * values can be changed if they were changed in the Daedalus definition
29 29
 	 * @param type $definition
30 30
 	 */
31
-	protected function updateDefinitionFromDds($definition, $includeAll=false)
31
+	protected function updateDefinitionFromDds($definition, $includeAll = false)
32 32
 	{
33 33
 		if (!empty($definition['renderables'])) {
34 34
 			$classes = $this->getDdsClassDefinitions($definition);
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 				}
163 163
 			}
164 164
 		}
165
-		if (count($newClassTypes)>0) {
165
+		if (count($newClassTypes) > 0) {
166 166
 			$newClasses = $this->ddsPhoebe()->getClasses($newClassTypes);
167 167
 			foreach ($newClasses as $newClass) {
168 168
 				$requestedClasses[$newClass->class_type] = $newClass;
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 					if (!isset($memberDefinition['definition'][$key]) || ($memberDefinition['definition'][$key] != $value))
186 186
 						$differences[$key] = $value;
187 187
 				}
188
-				$renderable['changes']=$differences;
188
+				$renderable['changes'] = $differences;
189 189
 			}
190 190
 		}
191 191
 	}
@@ -198,10 +198,10 @@  discard block
 block discarded – undo
198 198
 	protected function sanitiseDefinition(&$definition)
199 199
 	{
200 200
 		/** Remove Orphaned Renderables **/
201
-		$items = [ $definition['rootNode'] ];
201
+		$items = [$definition['rootNode']];
202 202
 		foreach ($definition['renderables'] as $renderable) {
203 203
 			if (isset($renderable['items'])) {
204
-				$items = array_merge($items,$renderable['items']);
204
+				$items = array_merge($items, $renderable['items']);
205 205
 			}
206 206
 		}
207 207
 		// remove renderables not linked via rootNode
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 			$uuid64s[] = Hash::uuid2uuid64($key);
229 229
 		}
230 230
 		$serialised = str_replace($keys, $uuid64s, $serialised);
231
-		$definition = json_decode($serialised,true);
231
+		$definition = json_decode($serialised, true);
232 232
 	}
233 233
 
234 234
 	private function ddsPhoebe()
Please login to merge, or discard this patch.
Braces   +18 added lines, -12 removed lines patch added patch discarded remove patch
@@ -54,8 +54,9 @@  discard block
 block discarded – undo
54 54
 	 */
55 55
 	protected function replaceDefinitionFromDds($definition)
56 56
 	{
57
-		if (empty($definition))
58
-			return [];
57
+		if (empty($definition)) {
58
+					return [];
59
+		}
59 60
 
60 61
 		$classes = $this->getDdsClassDefinitions($definition);
61 62
 		foreach ($definition['renderables'] as &$renderable) {
@@ -100,8 +101,9 @@  discard block
 block discarded – undo
100 101
 				$parentClassId = null;
101 102
 				if (isset($r['parentClassId'])) {
102 103
 					$parentClassId = $r['parentClassId'];
103
-					if (!in_array($r['parentClassId'], $renderableKeys))
104
-						$parentClassId = $this->findParentClassIdFromType($r['parentClassId'], $definition['renderables']);
104
+					if (!in_array($r['parentClassId'], $renderableKeys)) {
105
+											$parentClassId = $this->findParentClassIdFromType($r['parentClassId'], $definition['renderables']);
106
+					}
105 107
 				}
106 108
 				$r['relations'] = [
107 109
 					[
@@ -117,8 +119,9 @@  discard block
 block discarded – undo
117 119
 	protected function findParentClassIdFromType($type, $renderables)
118 120
 	{
119 121
 		foreach ($renderables as $r) {
120
-			if ($this->isClass($r) && $r['class_type'] == $type)
121
-				return $r['id'];
122
+			if ($this->isClass($r) && $r['class_type'] == $type) {
123
+							return $r['id'];
124
+			}
122 125
 		}
123 126
 		// can't find it so return the original so as not to break anything
124 127
 		return $type;
@@ -169,8 +172,9 @@  discard block
 block discarded – undo
169 172
 			}
170 173
 		}
171 174
 		$definitions = [];
172
-		foreach ($requiredClassTypes as $rct)
173
-			$definitions[$rct] = isset($requestedClasses[$rct]) ? $requestedClasses[$rct]->definition : null;
175
+		foreach ($requiredClassTypes as $rct) {
176
+					$definitions[$rct] = isset($requestedClasses[$rct]) ? $requestedClasses[$rct]->definition : null;
177
+		}
174 178
 		return $definitions;
175 179
 	}
176 180
 
@@ -182,8 +186,9 @@  discard block
 block discarded – undo
182 186
 				$memberDefinition = $classes[$renderable['class_type']]['fields'][$renderable['member_ref']];
183 187
 				$differences = [];
184 188
 				foreach ($renderDefinition as $key=>$value) {
185
-					if (!isset($memberDefinition['definition'][$key]) || ($memberDefinition['definition'][$key] != $value))
186
-						$differences[$key] = $value;
189
+					if (!isset($memberDefinition['definition'][$key]) || ($memberDefinition['definition'][$key] != $value)) {
190
+											$differences[$key] = $value;
191
+					}
187 192
 				}
188 193
 				$renderable['changes']=$differences;
189 194
 			}
@@ -233,8 +238,9 @@  discard block
 block discarded – undo
233 238
 
234 239
 	private function ddsPhoebe()
235 240
 	{
236
-		if (!$this->_ddsPhoebe)
237
-			$this->_ddsPhoebe = neon('phoebe')->getIPhoebeType('daedalus');
241
+		if (!$this->_ddsPhoebe) {
242
+					$this->_ddsPhoebe = neon('phoebe')->getIPhoebeType('daedalus');
243
+		}
238 244
 		return $this->_ddsPhoebe;
239 245
 	}
240 246
 	private $_ddsPhoebe = null;
Please login to merge, or discard this patch.
neon/phoebe/services/adapters/common/PhoebeObjectBase.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 	/**
122 122
 	 * @inheritdoc
123 123
 	 */
124
-	public function setOverride($overrideUuid, $force=false)
124
+	public function setOverride($overrideUuid, $force = false)
125 125
 	{
126 126
 		// don't override an override unless forced to do so
127 127
 		if (!$force && $this->override_uuid)
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 	/**
151 151
 	 * @inheritdoc
152 152
 	 */
153
-	public function listHistory(&$paginator=[])
153
+	public function listHistory(&$paginator = [])
154 154
 	{
155 155
 		// check the inputs
156 156
 		$paginator = $this->createPaginator($paginator);
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 		$query = ObjectHistoryModel::find()
159 159
 			->where(['object_uuid' => $this->uuid]);
160 160
 
161
-		if ($paginator['start']==0)
161
+		if ($paginator['start'] == 0)
162 162
 			$paginator['total'] = $query->count();
163 163
 
164 164
 		// and get the results
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 		$hmodel->override_uuid = $this->override_uuid;
238 238
 		$hmodel->serialised_data = $this->serialised_data;
239 239
 		if (!$hmodel->save())
240
-			throw new \RuntimeException("Failed to save the history of the object. Model errors were ".print_r($hmodel->errors,true));
240
+			throw new \RuntimeException("Failed to save the history of the object. Model errors were ".print_r($hmodel->errors, true));
241 241
 	}
242 242
 
243 243
 }
244 244
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +21 added lines, -14 removed lines patch added patch discarded remove patch
@@ -42,15 +42,17 @@  discard block
 block discarded – undo
42 42
 		// NOTE - changes are only saved into $this->data and not
43 43
 		// to the phoebe object in general.
44 44
 
45
-		if (empty($changes) || $changes == $this->data)
46
-			return true;
45
+		if (empty($changes) || $changes == $this->data) {
46
+					return true;
47
+		}
47 48
 
48 49
 		// Get the associated class object
49 50
 		$classType = $this->getClassType();
50 51
 		$class = $this->getClassModel($classType);
51 52
 
52
-		if (!$class)
53
-			throw new \RuntimeException("Class of type '$classType' not found. Can't save objects of unknown types");
53
+		if (!$class) {
54
+					throw new \RuntimeException("Class of type '$classType' not found. Can't save objects of unknown types");
55
+		}
54 56
 
55 57
 		// save the history object
56 58
 		if ($class->object_history) {
@@ -58,15 +60,17 @@  discard block
 block discarded – undo
58 60
 		}
59 61
 
60 62
 		// update the version if the class is not version locked
61
-		if (!$class->version_locked)
62
-			$this->version = $class->version;
63
+		if (!$class->version_locked) {
64
+					$this->version = $class->version;
65
+		}
63 66
 
64 67
 		// merge the changes and save the model
65 68
 		$this->data = $changes;
66 69
 		$this->updated = date('Y-m-d H:i:s');
67 70
 		$model = $this->getModel();
68
-		if (!$model->save())
69
-			return $model->errors;
71
+		if (!$model->save()) {
72
+					return $model->errors;
73
+		}
70 74
 		return true;
71 75
 	}
72 76
 
@@ -124,8 +128,9 @@  discard block
 block discarded – undo
124 128
 	public function setOverride($overrideUuid, $force=false)
125 129
 	{
126 130
 		// don't override an override unless forced to do so
127
-		if (!$force && $this->override_uuid)
128
-			return false;
131
+		if (!$force && $this->override_uuid) {
132
+					return false;
133
+		}
129 134
 
130 135
 		// Get the associated class object and check the override applies to this class
131 136
 		if ($this->getClassOverrideModel($overrideUuid, $this->version)) {
@@ -158,8 +163,9 @@  discard block
 block discarded – undo
158 163
 		$query = ObjectHistoryModel::find()
159 164
 			->where(['object_uuid' => $this->uuid]);
160 165
 
161
-		if ($paginator['start']==0)
162
-			$paginator['total'] = $query->count();
166
+		if ($paginator['start']==0) {
167
+					$paginator['total'] = $query->count();
168
+		}
163 169
 
164 170
 		// and get the results
165 171
 		return $query->offset($paginator['start'])
@@ -236,8 +242,9 @@  discard block
 block discarded – undo
236 242
 		$hmodel->version = $this->version;
237 243
 		$hmodel->override_uuid = $this->override_uuid;
238 244
 		$hmodel->serialised_data = $this->serialised_data;
239
-		if (!$hmodel->save())
240
-			throw new \RuntimeException("Failed to save the history of the object. Model errors were ".print_r($hmodel->errors,true));
245
+		if (!$hmodel->save()) {
246
+					throw new \RuntimeException("Failed to save the history of the object. Model errors were ".print_r($hmodel->errors,true));
247
+		}
241 248
 	}
242 249
 
243 250
 }
244 251
\ No newline at end of file
Please login to merge, or discard this patch.
neon/phoebe/services/adapters/common/models/PhoebeObject.php 1 patch
Braces   +17 added lines, -12 removed lines patch added patch discarded remove patch
@@ -70,10 +70,11 @@  discard block
 block discarded – undo
70 70
 	public function beforeSave($insert)
71 71
 	{
72 72
 		// data can only be an array and are stored as JSON
73
-		if (is_array($this->data) && count($this->data))
74
-			$this->serialised_data = json_encode($this->data);
75
-		else
76
-			$this->serialised_data = null;
73
+		if (is_array($this->data) && count($this->data)) {
74
+					$this->serialised_data = json_encode($this->data);
75
+		} else {
76
+					$this->serialised_data = null;
77
+		}
77 78
 		return parent::beforeSave($insert);
78 79
 	}
79 80
 
@@ -83,8 +84,9 @@  discard block
 block discarded – undo
83 84
 	public function afterFind()
84 85
 	{
85 86
 		// return data as decoded json or null
86
-		if (is_string($this->serialised_data))
87
-			$this->data = json_decode($this->serialised_data, true);
87
+		if (is_string($this->serialised_data)) {
88
+					$this->data = json_decode($this->serialised_data, true);
89
+		}
88 90
 		parent::afterFind();
89 91
 	}
90 92
 
@@ -101,14 +103,17 @@  discard block
 block discarded – undo
101 103
 		}
102 104
 		$query = PhoebeObject::find()->select(['phoebe_object.uuid', 'phoebe_class.label'])
103 105
 			->leftJoin('phoebe_class', 'phoebe_class.phoebe_type=phoebe_object.phoebe_type AND phoebe_class.class_type=phoebe_object.class_type');
104
-		if (!empty($query))
105
-			$query->where(['like', 'phoebe_class.label', $query]);
106
-		if (count($filters))
107
-			$query->andWhere($filters);
106
+		if (!empty($query)) {
107
+					$query->where(['like', 'phoebe_class.label', $query]);
108
+		}
109
+		if (count($filters)) {
110
+					$query->andWhere($filters);
111
+		}
108 112
 		$objects = $query->orderBy('phoebe_class.label')->asArray()->all();
109 113
 		$results = [];
110
-		foreach ($objects as $object)
111
-			$results[$object['uuid']] = "$object[label]: $object[uuid]";
114
+		foreach ($objects as $object) {
115
+					$results[$object['uuid']] = "$object[label]: $object[uuid]";
116
+		}
112 117
 		return $results;
113 118
 	}
114 119
 }
Please login to merge, or discard this patch.
neon/phoebe/services/adapters/common/models/PhoebeClassOverrides.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -121,7 +121,7 @@
 block discarded – undo
121 121
 	/**
122 122
 	 * @inheritdoc
123 123
 	 */
124
-	public function toArray(array $fields=[], array $expand=[], $recursive=true)
124
+	public function toArray(array $fields = [], array $expand = [], $recursive = true)
125 125
 	{
126 126
 		$data = parent::toArray($fields, $expand, $recursive);
127 127
 		unset($data['serialised_overrides']);
Please login to merge, or discard this patch.
Braces   +6 added lines, -5 removed lines patch added patch discarded remove patch
@@ -99,9 +99,9 @@  discard block
 block discarded – undo
99 99
 	{
100 100
 		// active_from must be set
101 101
 		// overrides can only be an array and are stored as JSON or already JSON
102
-		if (is_array($this->overrides) && count($this->overrides))
103
-			$this->serialised_overrides = json_encode($this->overrides);
104
-		else {
102
+		if (is_array($this->overrides) && count($this->overrides)) {
103
+					$this->serialised_overrides = json_encode($this->overrides);
104
+		} else {
105 105
 			$this->serialised_overrides = null;
106 106
 		}
107 107
 		return parent::beforeSave($insert);
@@ -113,8 +113,9 @@  discard block
 block discarded – undo
113 113
 	public function afterFind()
114 114
 	{
115 115
 		// return overrides as decoded json or null
116
-		if (is_string($this->serialised_overrides))
117
-			$this->overrides = json_decode($this->serialised_overrides, true);
116
+		if (is_string($this->serialised_overrides)) {
117
+					$this->overrides = json_decode($this->serialised_overrides, true);
118
+		}
118 119
 		parent::afterFind();
119 120
 	}
120 121
 
Please login to merge, or discard this patch.
neon/phoebe/services/adapters/common/models/PhoebeClass.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -103,7 +103,7 @@
 block discarded – undo
103 103
 		parent::afterFind();
104 104
 	}
105 105
 
106
-	public function toArray(array $fields=[], array $expand=[], $recursive=true)
106
+	public function toArray(array $fields = [], array $expand = [], $recursive = true)
107 107
 	{
108 108
 		$data = parent::toArray($fields, $expand, $recursive);
109 109
 		unset($data['serialised_definition']);
Please login to merge, or discard this patch.
Braces   +15 added lines, -11 removed lines patch added patch discarded remove patch
@@ -84,9 +84,9 @@  discard block
 block discarded – undo
84 84
 	public function beforeSave($insert)
85 85
 	{
86 86
 		// definition can only be an array and are stored as JSON or already JSON
87
-		if (is_array($this->definition) && count($this->definition))
88
-			$this->serialised_definition = json_encode($this->definition);
89
-		else {
87
+		if (is_array($this->definition) && count($this->definition)) {
88
+					$this->serialised_definition = json_encode($this->definition);
89
+		} else {
90 90
 			$this->serialised_definition = null;
91 91
 		}
92 92
 		return parent::beforeSave($insert);
@@ -98,8 +98,9 @@  discard block
 block discarded – undo
98 98
 	public function afterFind()
99 99
 	{
100 100
 		// return definition as decoded json or null
101
-		if (is_string($this->serialised_definition))
102
-			$this->definition = json_decode($this->serialised_definition, true);
101
+		if (is_string($this->serialised_definition)) {
102
+					$this->definition = json_decode($this->serialised_definition, true);
103
+		}
103 104
 		parent::afterFind();
104 105
 	}
105 106
 
@@ -120,14 +121,17 @@  discard block
 block discarded – undo
120 121
 	public static function listClassTypes($query, $filters)
121 122
 	{
122 123
 		$query = PhoebeClass::find()->select(['class_type', 'label']);
123
-		if (!empty($query))
124
-			$query->where(['like', 'label', $query]);
125
-		if (count($filters))
126
-			$query->where($filters);
124
+		if (!empty($query)) {
125
+					$query->where(['like', 'label', $query]);
126
+		}
127
+		if (count($filters)) {
128
+					$query->where($filters);
129
+		}
127 130
 		$classes = $query->orderBy('label')->asArray()->all();
128 131
 		$results = [];
129
-		foreach ($classes as $class)
130
-			$results[$class['class_type']] = $class['label'];
132
+		foreach ($classes as $class) {
133
+					$results[$class['class_type']] = $class['label'];
134
+		}
131 135
 		return $results;
132 136
 	}
133 137
 }
Please login to merge, or discard this patch.