Completed
Pull Request — master (#33)
by Glenn
02:19
created

StaffController   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 3
Bugs 2 Features 0
Metric Value
wmc 3
c 3
b 2
f 0
lcom 0
cbo 1
dl 0
loc 20
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A index() 0 5 1
A profile() 0 4 1
1
<?php
2
3
namespace App\Http\Controllers;
4
5
use Illuminate\Http\Request;
6
7
use App\Http\Requests;
8
9
class StaffController extends Controller
10
{
11
12
    public function __construct()
13
    {
14
        $this->middleware('auth');
15
    }
16
17
	public function index()
18
	{
19
		$data['users'] = User::all();
0 ignored issues
show
Coding Style Comprehensibility introduced by
$data was never initialized. Although not strictly required by PHP, it is generally a good practice to add $data = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
20
    	return view('users/index', $data);
21
    }
22
23
24
    public function profile()
25
    {
26
    	return view('users/profile');
27
    }
28
}
29