LiveLeaderboardController::store()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

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 1
nc 1
nop 0
1
<?php
2
3
use GolfLeague\Services\LeaderboardService;
4
5
6
class LiveLeaderboardController 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(LeaderboardService $leaderboard)
9
    {
10
        $this->leaderboard = $leaderboard;
11
    }
12
13
    /**
14
	 * Display a listing of the resource.
15
	 *
16
	 * @return Response
17
	 */
18
	public function index()
19
	{
20
		return 'LIVE!';
21
	}
22
23
24
	/**
25
	 * Show the form for creating a new resource.
26
	 *
27
	 * @return Response
28
	 */
29
	public function create()
30
	{
31
		//
32
	}
33
34
35
	/**
36
	 * Store a newly created resource in storage.
37
	 *
38
	 * @return Response
39
	 */
40
	public function store()
41
	{
42
		//
43
	}
44
45
46
	/**
47
	 * Display the specified resource.
48
	 *
49
	 * @param  int  $id
50
	 * @return Response
51
	 */
52
	public function show($id)
53
	{
54
        $match = Input::get('match');
55
        $type = $id;
56
57
        //return net or gross leaderboard for live scoring
58
		$data['data'] = $this->leaderboard->calculate($match,$type);
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...
59
        return $data;
60
61
	}
62
63
64
	/**
65
	 * Show the form for editing the specified resource.
66
	 *
67
	 * @param  int  $id
68
	 * @return Response
69
	 */
70
	public function edit($id)
71
	{
72
		//
73
	}
74
75
76
	/**
77
	 * Update the specified resource in storage.
78
	 *
79
	 * @param  int  $id
80
	 * @return Response
81
	 */
82
	public function update($id)
83
	{
84
		//
85
	}
86
87
88
	/**
89
	 * Remove the specified resource from storage.
90
	 *
91
	 * @param  int  $id
92
	 * @return Response
93
	 */
94
	public function destroy($id)
95
	{
96
		//
97
	}
98
99
100
}
101