LeaderboardController::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
use GolfLeague\Storage\Leaderboard\LeaderboardRepository as LeaderboardRepository;
4
5
class LeaderboardController extends \BaseController {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
6
7
	public function __construct(LeaderboardRepository $leaderboardRepo)
8
    {
9
        $this->leaderboardRepo = $leaderboardRepo;
10
    }
11
	/**
12
	 * Display a listing of the resource.
13
	 *
14
	 * @return Response
15
	 */
16
	public function index()
17
	{
18
		return View::make('leaderboard');
19
	}
20
21
	/**
22
	 * Display the specified resource.
23
	 *
24
	 * @param  int  $id
0 ignored issues
show
Bug introduced by
There is no parameter named $id. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
25
	 * @return Response
26
	 */
27
	public function show($year)
28
	{
29
		$results  = $this->leaderboardRepo->get($year);
30
		$newvalue = array_values( (array)$results );
31
		$data['data'] = $newvalue;
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...
32
		return $data;
33
	}
34
35
36
	/**
37
	 * Show the form for editing the specified resource.
38
	 *
39
	 * @param  int  $id
40
	 * @return Response
41
	 */
42
	public function edit($id)
43
	{
44
		//
45
	}
46
47
48
	/**
49
	 * Update the specified resource in storage.
50
	 *
51
	 * @param  int  $id
52
	 * @return Response
53
	 */
54
	public function update($id)
55
	{
56
		//
57
	}
58
59
60
	/**
61
	 * Remove the specified resource from storage.
62
	 *
63
	 * @param  int  $id
64
	 * @return Response
65
	 */
66
	public function destroy($id)
67
	{
68
		//
69
	}
70
71
72
}
73