Passed
Push — master ( 5ca280...347b45 )
by Georgi
02:45
created

DashboardNavMenu   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 20
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A items() 0 18 3
1
<?php 
2
3
namespace Epesi\Base\Dashboard\Integration;
4
5
use Epesi\Base\Layout\Integration\Joints\NavMenuJoint;
6
use Epesi\Base\Dashboard\Database\Models\Dashboard;
7
use Illuminate\Support\Facades\Auth;
8
use Epesi\Core\Integration\ModuleView;
0 ignored issues
show
Bug introduced by
The type Epesi\Core\Integration\ModuleView was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
10
class DashboardNavMenu extends NavMenuJoint
11
{
12
	public function items()
13
	{
14
		$ret = [];
15
		
16
		foreach (Dashboard::where(['user_id' => Auth::user()->id])->orderBy('position')->get() as $dashboard) {
0 ignored issues
show
Bug introduced by
Accessing id on the interface Illuminate\Contracts\Auth\Authenticatable suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
17
			$ret[$dashboard->name] = [
18
					'access' => true,
19
					'weight' => $dashboard['position'],
20
					'link' => ModuleView::moduleLink('dashboard', 'body', ['dashboard' => $dashboard->id])
21
			];
22
		}
23
24
		return [
25
				__('DASHBOARD') => count($ret) > 1? [
26
						'access' => true,
27
						'group' => $ret,
28
						'weight' => -10000
29
				]: array_merge(reset($ret), ['weight' => -10000]),
30
		];
31
	}
32
}