Passed
Push — master ( a37889...b0889b )
by Georgi
03:24
created
src/Dashboard/Seeds/Applet.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@
 block discarded – undo
28 28
 			$this->set($joint->info())->setAttr('searchkey', strtolower($joint->caption() . ';' . $joint->info()));
29 29
 		}
30 30
 		else {
31
-			if (! $this->locked) {
31
+			if (!$this->locked) {
32 32
 				$this->addControl('close', 'applet-close')->setAttr('title', __('Close applet'));
33 33
 			}
34 34
 			
Please login to merge, or discard this patch.
src/Dashboard/Integration/DashboardNavMenu.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -21,12 +21,12 @@
 block discarded – undo
21 21
 			];
22 22
 		}
23 23
 
24
-		return $ret? [
25
-				__('DASHBOARD') => count($ret) > 1? [
24
+		return $ret ? [
25
+				__('DASHBOARD') => count($ret) > 1 ? [
26 26
 						'access' => true,
27 27
 						'group' => $ret,
28 28
 						'weight' => -10000
29
-				]: array_merge(reset($ret), ['weight' => -10000]),
30
-		]: [];
29
+				] : array_merge(reset($ret), ['weight' => -10000]),
30
+		] : [];
31 31
 	}
32 32
 }
33 33
\ No newline at end of file
Please login to merge, or discard this patch.
src/Dashboard/DashboardView.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	
25 25
 	public function body()
26 26
 	{
27
-		if (! $this->isSingleDashboard()) {
27
+		if (!$this->isSingleDashboard()) {
28 28
 			$this->location($this->dashboard()->name);
29 29
 		}
30 30
 		
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 		
43 43
 		$applets = $dashboard->applets()->orderBy('column')->orderBy('row')->get();
44 44
 
45
-		$columns = $this->add(['Columns', 'id' => 'dashboard', 'ui' => 'three stackable grid'  . ($this->isLocked()? ' locked': '')]);
45
+		$columns = $this->add(['Columns', 'id' => 'dashboard', 'ui' => 'three stackable grid' . ($this->isLocked() ? ' locked' : '')]);
46 46
 		
47 47
 		foreach ([1, 2, 3] as $columnId) {
48 48
 			/** @scrutinizer ignore-call */
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 					]
56 56
 			]);
57 57
 			
58
-			foreach ($applets->where('column', $columnId) as $applet ) {
58
+			foreach ($applets->where('column', $columnId) as $applet) {
59 59
 				$col->add([
60 60
 						new Applet(),
61 61
 						'appletId' => $applet->id,
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 			}
67 67
 		}
68 68
 		
69
-		if (! $this->isLocked()) {
69
+		if (!$this->isLocked()) {
70 70
 			$columns->js(true)->find('.sortable')->sortable([
71 71
 					'cursor' => 'move',
72 72
 					'handle' => '.panel-sortable-handle',
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 					])
85 85
 			]));
86 86
 			
87
-			$columns->js(true)->find('.applet-close')->click(new jsFunction(['e'], [new jsExpression('if (confirm("' .  __('Delete this applet?') . '")) {$(e.target).closest(".applet").fadeOut(400, function(){var col = $(this).closest(".column.sortable");this.remove();col.trigger("sortupdate");})}')]));
87
+			$columns->js(true)->find('.applet-close')->click(new jsFunction(['e'], [new jsExpression('if (confirm("' . __('Delete this applet?') . '")) {$(e.target).closest(".applet").fadeOut(400, function(){var col = $(this).closest(".column.sortable");this.remove();col.trigger("sortupdate");})}')]));
88 88
 		}
89 89
 		
90 90
 		$this->columns = $columns;
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 				]
132 132
 		]);
133 133
 
134
-		foreach ( AppletJoint::collect() as $applet ) {
134
+		foreach (AppletJoint::collect() as $applet) {
135 135
 			$col->add([
136 136
 					new Applet(),
137 137
 					'appletId' => 'new_' . str_ireplace('\\', '-', get_class($applet)),
@@ -260,10 +260,10 @@  discard block
 block discarded – undo
260 260
 	{
261 261
 		$dashboard = Dashboard::find($dashboardId);
262 262
 
263
-		return $dashboard->delete()? [
263
+		return $dashboard->delete() ? [
264 264
 				$this->notify(__('Dashboard ":name" deleted, redirecting ...', ['name' => $dashboard->name])),
265 265
 				new jsExpression('window.setTimeout(function() {window.location.replace([])}, 1200)', [self::selfLink()])
266
-		]: $this->notifyError(__('Error deleting dashboard'));
266
+		] : $this->notifyError(__('Error deleting dashboard'));
267 267
 	}
268 268
 	
269 269
 	public function reorderDashboards($view)
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 		$grid = $view->add(['Grid', 'paginator' => false, 'menu' => false]);
283 283
 		$grid->setModel(new \atk4\data\Model(new \atk4\data\Persistence_Static($rows)));
284 284
 		
285
-		$grid->addDragHandler()->onReorder(function ($order) use ($dashboards) {
285
+		$grid->addDragHandler()->onReorder(function($order) use ($dashboards) {
286 286
 			$result = true;
287 287
 			foreach ($dashboards as $dashboard) {
288 288
 				$dashboard->position = array_search($dashboard->id, $order);
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 				$result &= $dashboard->save();
291 291
 			}
292 292
 			
293
-			return $result? $this->notify(__('Dashboards reordered!')): $this->notifyError(__('Error saving order!'));
293
+			return $result ? $this->notify(__('Dashboards reordered!')) : $this->notifyError(__('Error saving order!'));
294 294
 		});
295 295
 			
296 296
 		$view->add(['View', 'ui' => 'buttons'])->add(['Button', __('Done'), 'primary'])->on('click', new jsExpression('location.reload()'));
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
 	
368 368
 	public function isLocked()
369 369
 	{
370
-		return $this->locked || ! Auth::user()->can('edit dashboard');
370
+		return $this->locked || !Auth::user()->can('edit dashboard');
371 371
 	}
372 372
 	
373 373
 	protected function isSingleDashboard()
@@ -383,18 +383,18 @@  discard block
 block discarded – undo
383 383
 	 */
384 384
 	protected function dashboard()
385 385
 	{
386
-		if (! is_object($this->dashboard)) {
387
-			$this->dashboard = $this->dashboard? Dashboard::find($this->dashboard): $this->defaultUserDashboard();
386
+		if (!is_object($this->dashboard)) {
387
+			$this->dashboard = $this->dashboard ? Dashboard::find($this->dashboard) : $this->defaultUserDashboard();
388 388
 		}
389 389
 
390
-		return $this->dashboard?: abort(404);
390
+		return $this->dashboard ?: abort(404);
391 391
 	}
392 392
 	
393 393
 	protected function defaultUserDashboard()
394 394
 	{
395 395
 		$userDashboard = $this->userDashboards()->orderBy('position')->first();
396 396
 		
397
-		if (! $userDashboard) {
397
+		if (!$userDashboard) {
398 398
 			$this->lock();
399 399
 			
400 400
 			$userDashboard = $this->defaultSystemDashboard();
@@ -418,6 +418,6 @@  discard block
 block discarded – undo
418 418
 	 */
419 419
 	protected function userId()
420 420
 	{
421
-		return $this->admin? 0: Auth::id();
421
+		return $this->admin ? 0 : Auth::id();
422 422
 	}
423 423
 }
Please login to merge, or discard this patch.
src/Dashboard/DashboardCore.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
31 31
 	{
32 32
 		// create user default dashboard as copy of the system default
33 33
 		User::created(function(User $user) {
34
-			if (! $defaultDashboard = Dashboard::where('user_id', 0)->first()) return;
34
+			if (!$defaultDashboard = Dashboard::where('user_id', 0)->first()) return;
35 35
 			
36 36
 			$userDefaultDashboard = $defaultDashboard->replicate();
37 37
 			
Please login to merge, or discard this patch.
Dashboard/Database/Migrations/2019_09_18_173148_create_dashboard_tables.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,14 +15,14 @@
 block discarded – undo
15 15
     {
16 16
     	$this->down();
17 17
     	
18
-    	Schema::create('dashboards', function (Blueprint $table) {
18
+    	Schema::create('dashboards', function(Blueprint $table) {
19 19
     		$table->increments('id');
20 20
     		$table->unsignedInteger('user_id');
21 21
             $table->string('name', 64);
22 22
             $table->smallInteger('position')->default(0);
23 23
         });
24 24
 
25
-    	Schema::create('dashboard_applets', function (Blueprint $table) {
25
+    	Schema::create('dashboard_applets', function(Blueprint $table) {
26 26
     		$table->increments('id');
27 27
     		$table->unsignedInteger('dashboard_id');
28 28
             $table->string('class', 512);            
Please login to merge, or discard this patch.
Database/Migrations/2019_11_10_213529_create_commondata_table.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
      */
14 14
     public function up()
15 15
     {
16
-        Schema::create('commondata', function (Blueprint $table) {
16
+        Schema::create('commondata', function(Blueprint $table) {
17 17
             $table->bigIncrements('id');            
18 18
             $table->nestedSet();
19 19
             
Please login to merge, or discard this patch.
src/CommonData/Database/Models/CommonData.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -24,11 +24,11 @@  discard block
 block discarded – undo
24 24
     public static function getId($path, $clearCache = false)
25 25
     {
26 26
     	$parentId = null;
27
-    	foreach(explode('/', trim($path,'/')) as $nodeKey) {
27
+    	foreach (explode('/', trim($path, '/')) as $nodeKey) {
28 28
     		if ($nodeKey === '') continue; //ignore empty paths
29 29
     		
30 30
     		if ($clearCache || empty(self::$cache['id'][$parentId][$nodeKey])) {
31
-    			if (! $node = self::where('parent_id', $parentId)->where('key', $nodeKey)->first()) {
31
+    			if (!$node = self::where('parent_id', $parentId)->where('key', $nodeKey)->first()) {
32 32
     				return false;
33 33
     			}
34 34
 
@@ -43,19 +43,19 @@  discard block
 block discarded – undo
43 43
    
44 44
     public static function newId($path, $readonly = false)
45 45
     {
46
-    	if (! $path = trim($path,'/')) return false;
46
+    	if (!$path = trim($path, '/')) return false;
47 47
 
48 48
     	$id = $parentId = null;
49
-    	foreach(explode('/', $path) as $nodeKey) {
49
+    	foreach (explode('/', $path) as $nodeKey) {
50 50
     		if ($nodeKey === '') continue;
51 51
 
52
-    		if (! $node = self::where('parent_id', $parentId)->where('key', $nodeKey)->first()) {
52
+    		if (!$node = self::where('parent_id', $parentId)->where('key', $nodeKey)->first()) {
53 53
     			$node = self::create([
54 54
     					'parent_id' => $parentId,
55 55
     					'key' => $nodeKey,
56 56
     					'readonly' => $readonly,
57 57
     					'position' => self::where('parent_id', $parentId)->count()
58
-    			], $parentId? self::find($parentId): null);
58
+    			], $parentId ? self::find($parentId) : null);
59 59
     		}
60 60
     		
61 61
     		$parentId = $id = $node->id;
@@ -66,10 +66,10 @@  discard block
 block discarded – undo
66 66
     
67 67
     public static function setValue($path, $value, $overwrite = true, $readonly = false)
68 68
     {
69
-    	if (! $id = self::getId($path)) {
70
-    		if (! $id = self::newId($path, $readonly)) return false;
69
+    	if (!$id = self::getId($path)) {
70
+    		if (!$id = self::newId($path, $readonly)) return false;
71 71
     	} else {
72
-    		if (! $overwrite) return false;
72
+    		if (!$overwrite) return false;
73 73
     	}
74 74
 
75 75
     	self::findOrFail($id)->update(compact('value', 'readonly'));
@@ -88,13 +88,13 @@  discard block
 block discarded – undo
88 88
     {
89 89
     	$key = md5(serialize($path));
90 90
     	
91
-    	if (! isset(self::$cache['value'][$key])) {
92
-    		if(! $id = self::getId($path)) return false;
91
+    	if (!isset(self::$cache['value'][$key])) {
92
+    		if (!$id = self::getId($path)) return false;
93 93
 
94 94
     		self::$cache['value'][$key] = self::find($id)->value;
95 95
 	    }
96 96
 	    
97
-	    return $translate? __(self::$cache['value'][$key]): self::$cache['value'][$key];
97
+	    return $translate ? __(self::$cache['value'][$key]) : self::$cache['value'][$key];
98 98
     }
99 99
         
100 100
     /**
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
     	$path = trim($path, '/');
113 113
     	
114 114
 		if ($id = self::getId($path)) {
115
-    		if (! $overwrite) {
115
+    		if (!$overwrite) {
116 116
     			self::extendArray($path, $array);
117 117
     			return true;
118 118
     		}
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
     		self::find($id)->delete();
121 121
     	}
122 122
     			
123
-    	if(! $id = self::newId($path, $readonly)) return false;
123
+    	if (!$id = self::newId($path, $readonly)) return false;
124 124
     			
125 125
     	if ($overwrite) {
126 126
     		self::find($id)->update(compact('readonly'));
@@ -140,13 +140,13 @@  discard block
 block discarded – undo
140 140
      * @param $array array values to insert
141 141
      * @param $overwrite bool whether method should overwrite data if array key already exists, otherwise the data will be preserved
142 142
      */
143
-    public static function extendArray($path, $array, $overwrite=false, $readonly=false)
143
+    public static function extendArray($path, $array, $overwrite = false, $readonly = false)
144 144
     {
145 145
     	self::validateArrayKeys($array);
146 146
     	
147 147
     	$path = trim($path, '/');
148 148
     			
149
-    	if (! self::getId($path)){
149
+    	if (!self::getId($path)) {
150 150
     		return self::newArray($path, $array, $overwrite, $readonly);
151 151
     	}
152 152
 
@@ -172,8 +172,8 @@  discard block
 block discarded – undo
172 172
      * @param $path string
173 173
      * @return true on success, false otherwise
174 174
      */
175
-    public static function deleteArray($path){
176
-    	if (! $id = self::getId($path, true)) return false;
175
+    public static function deleteArray($path) {
176
+    	if (!$id = self::getId($path, true)) return false;
177 177
     	
178 178
     	self::find($id)->delete();
179 179
     	
@@ -188,11 +188,11 @@  discard block
 block discarded – undo
188 188
      */
189 189
     public static function getCollection($path, $silent = false)
190 190
     {
191
-    	if(isset(self::$cache['array'][$path])) {
191
+    	if (isset(self::$cache['array'][$path])) {
192 192
     		return self::$cache['array'][$path];
193 193
     	}
194 194
     	
195
-    	if (! $id = self::getId($path)) {
195
+    	if (!$id = self::getId($path)) {
196 196
     		if ($silent) return collect();
197 197
     		
198 198
     		throw new CommonDataNotFound('Invalid CommonData::getArray() request: ' . $path);
@@ -203,10 +203,10 @@  discard block
 block discarded – undo
203 203
     
204 204
     protected static function validateArrayKeys($array)
205 205
     {
206
-    	foreach($array as $key => $value) {
206
+    	foreach ($array as $key => $value) {
207 207
     		if (strpos($key, '/') === false) continue;
208 208
     		
209
-    		\Exception('Invalid common data key: '. $key);
209
+    		\Exception('Invalid common data key: ' . $key);
210 210
     	}
211 211
     }
212 212
 }
213 213
\ No newline at end of file
Please login to merge, or discard this patch.
src/CommonData/CommonDataSettings.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	{
31 31
 		ActionBar::addButton('back')->link(url('view/system'));
32 32
 		
33
-		$this->parentId = $this->stickyGet('parentId')?: null;
33
+		$this->parentId = $this->stickyGet('parentId') ?: null;
34 34
 		
35 35
 		$this->displayBreadCrumb();
36 36
 		
@@ -75,14 +75,14 @@  discard block
 block discarded – undo
75 75
 
76 76
 		$this->grid->setModel($model = $this->getModel());
77 77
 		
78
-		if ($model->action('count')->getOne() ) {
78
+		if ($model->action('count')->getOne()) {
79 79
 			$this->grid->on('click', 'td', new jsExpression(
80 80
 					'document.location=\'?parentId=\'+[]',
81 81
 					[(new jQuery())->closest('tr')->data('id')]
82 82
 			));
83 83
 		}
84 84
 		
85
-		$this->grid->addDragHandler()->onReorder(function ($order) {
85
+		$this->grid->addDragHandler()->onReorder(function($order) {
86 86
 			$result = true;
87 87
 			foreach ($this->nodes()->get() as $node) {
88 88
 				$node->position = array_search($node->id, $order);
@@ -90,14 +90,14 @@  discard block
 block discarded – undo
90 90
 				$result &= $node->save();
91 91
 			}
92 92
 			
93
-			$notifier = $result? $this->notify(__('Items reordered!')): $this->notifyError(__('Error saving order!'));
93
+			$notifier = $result ? $this->notify(__('Items reordered!')) : $this->notifyError(__('Error saving order!'));
94 94
 			
95 95
 			return $this->grid->jsSave($notifier);
96 96
 		});
97 97
 		
98 98
 		$this->addContolButton('update', $this->getUpdateModal(), 'edit');
99 99
 			
100
-		$this->addContolButton('delete', function ($jschain, $id) {
100
+		$this->addContolButton('delete', function($jschain, $id) {
101 101
 			CommonData::find($id)->delete();
102 102
 				
103 103
 			return $jschain->closest('tr')->transition('fade left');
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 			$ret .= $button->getHtml();
120 120
 		}
121 121
 		
122
-		return $ret;;
122
+		return $ret; ;
123 123
 	}
124 124
 	
125 125
 	public function getUpdateModal()
@@ -128,9 +128,9 @@  discard block
 block discarded – undo
128 128
 		
129 129
 		$grid->pageUpdate = $grid->add($grid->pageUpdate ?: $grid->pageDefault, ['short_name'=>'edit']);
130 130
 		
131
-		$modal = new jsModal(__('Edit'), $grid->pageUpdate, [$grid->name => $grid->jsRow()->data('id'), $grid->name.'_sort' => $grid->getSortBy()]);
131
+		$modal = new jsModal(__('Edit'), $grid->pageUpdate, [$grid->name => $grid->jsRow()->data('id'), $grid->name . '_sort' => $grid->getSortBy()]);
132 132
 		
133
-		$grid->pageUpdate->set(function () {
133
+		$grid->pageUpdate->set(function() {
134 134
 			$grid = $this->grid;
135 135
 			
136 136
 			$grid->model->load($grid->app->stickyGet($grid->name));
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 			// set save handler with reload trigger
150 150
 			// adds default submit hook if it is not already set for this form
151 151
 			if (!$grid->formUpdate->hookHasCallbacks('submit')) {
152
-				$grid->formUpdate->onSubmit(function ($form) {
152
+				$grid->formUpdate->onSubmit(function($form) {
153 153
 					$form->model->save();
154 154
 					
155 155
 					return $this->grid->jsSaveUpdate();
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 		
167 167
 		$this->grid->on('click', ".$class", $callback, [$this->grid->table->jsRow()->data('id')]);
168 168
 		
169
-		$this->buttons[$name] = new \atk4\ui\Button($icon? compact('icon'): $name);
169
+		$this->buttons[$name] = new \atk4\ui\Button($icon ? compact('icon') : $name);
170 170
 		
171 171
 		$this->buttons[$name]->app = $this->app;
172 172
 		
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 		
194 194
 		$rowsEmpty = [];
195 195
 		
196
-		$model = new \atk4\data\Model($rows? new \atk4\data\Persistence_Static($rows): new \atk4\data\Persistence_Array($rowsEmpty));
196
+		$model = new \atk4\data\Model($rows ? new \atk4\data\Persistence_Static($rows) : new \atk4\data\Persistence_Array($rowsEmpty));
197 197
 		
198 198
 		$captions = [
199 199
 				'position' => __('Position'),
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 		];
204 204
 		
205 205
 		foreach ($captions as $key => $caption) {
206
-			$field = $rows? $model->hasField($key): $model->addField($key);
206
+			$field = $rows ? $model->hasField($key) : $model->addField($key);
207 207
 			
208 208
 			if ($key === 'readonly') {
209 209
 				$field->setDefaults(['ui' => ['visible' => false]]);
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 	
220 220
 	public function getNodeForm()
221 221
 	{
222
-		if (! $this->form) {
222
+		if (!$this->form) {
223 223
 			$this->form = new Form(['buttonSave' => ['Button', __('Save'), 'primary']]);
224 224
 			
225 225
 			$this->form->addHook('submit', function($form) {
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 				
234 234
 				CommonData::create(array_merge($values, [
235 235
 						'position' => $this->nodes()->max('position') + 1
236
-				]), $this->parentId? CommonData::find($this->parentId): null);
236
+				]), $this->parentId ? CommonData::find($this->parentId) : null);
237 237
 				
238 238
 				return $this->grid->jsSaveCreate();
239 239
 			});
Please login to merge, or discard this patch.