SkinsController::__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\Statistics\League\LeagueStatistics as LeagueStatistics;
4
5
6
class SkinsController 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...
7
8
	public function __construct(LeagueStatistics $leagueStatistics)
9
    {
10
		$this->leagueStatistics = $leagueStatistics;
11
    }
12
13
    /**
14
	 * Display a listing of the resource.
15
	 *
16
	 * @return Response
17
	 */
18
	public function index()
19
	{
20
		//may use for get all
21
	}
22
23
24
	/**
25
	 * Display the specified resource.
26
	 *
27
	 * @param  int  $id
28
	 * @return Response
29
	 */
30
	public function show($id)
31
	{
32
		$results  = $this->leagueStatistics->mostSkinsByYear($id);
33
		$newvalue = array_values( (array)$results );
34
		$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...
35
		return $data;
36
	}
37
38
39
40
}
41