BirdController::index()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 4
Ratio 100 %

Importance

Changes 0
Metric Value
dl 4
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
3
use GolfLeague\Statistics\League\LeagueStatistics as LeagueStatistics;
4
5
6 View Code Duplication
class BirdController extends \BaseController {
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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->totalBirdies($id);
33
		$data['data'] = $results;
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...
34
		return $data;
35
	}
36
37
38
39
}
40