RoundsController   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 84
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 8
lcom 0
cbo 1
dl 0
loc 84
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 4 1
A store() 0 4 1
A edit() 0 4 1
A update() 0 4 1
A destroy() 0 4 1
A __construct() 0 4 1
A index() 0 4 1
A show() 0 6 1
1
<?php
2
3
use GolfLeague\Storage\Round\RoundRepository as RoundRepo;
4
5
class RoundsController 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(RoundRepo $roundRepo)
8
    {
9
		$this->roundRepo = $roundRepo;
10
    }
11
12
	/**
13
	 * Get Data for all rounds
14
	 *
15
	 * @return Response
16
	 */
17
	public function index()
18
	{
19
		return $this->roundRepo->all();
20
	}
21
22
	/**
23
	 * Show the form for creating a new resource.
24
	 *
25
	 * @return Response
26
	 */
27
	public function create()
28
	{
29
		//
30
	}
31
32
	/**
33
	 * Store a newly created resource in storage.
34
	 *
35
	 * @return Response
36
	 */
37
	public function store()
38
	{
39
		//
40
	}
41
42
	/**
43
	 * Display the specified resource.
44
	 *
45
	 * @param  int  $id
46
	 * @return Response
47
	 */
48
	public function show($id)
49
	{
50
		$results  = $this->roundRepo->findByPlayer($id);
51
		$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...
52
		return $data;
53
	}
54
55
	/**
56
	 * Show the form for editing the specified resource.
57
	 *
58
	 * @param  int  $id
59
	 * @return Response
60
	 */
61
	public function edit($id)
62
	{
63
		//
64
	}
65
66
	/**
67
	 * Update the specified resource in storage.
68
	 *
69
	 * @param  int  $id
70
	 * @return Response
71
	 */
72
	public function update($id)
73
	{
74
		//
75
	}
76
77
	/**
78
	 * Remove the specified resource from storage.
79
	 *
80
	 * @param  int  $id
81
	 * @return Response
82
	 */
83
	public function destroy($id)
84
	{
85
		//
86
	}
87
88
}