HoleScoresController   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 91
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 8
lcom 0
cbo 2
dl 0
loc 91
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A index() 0 5 1
A create() 0 4 1
A store() 0 4 1
A show() 0 4 1
A edit() 0 4 1
A destroy() 0 4 1
A update() 0 5 1
1
<?php
2
3
use GolfLeague\Services\ScoreService as HoleScore;
0 ignored issues
show
Bug introduced by
This use statement conflicts with another class in this namespace, HoleScore.

Let’s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let’s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
4
5
class HoleScoresController 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(HoleScore $holeScore)
8
    {
9
		$this->holeScore = $holeScore;
10
    }
11
12
	/**
13
	 * Display a listing of the resource.
14
	 *
15
	 * @return Response
16
	 */
17
	public function index()
18
	{
19
		$data = $this->holeScore->all();
20
        return $data;
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
		//
55
	}
56
57
58
	/**
59
	 * Show the form for editing the specified resource.
60
	 *
61
	 * @param  int  $id
62
	 * @return Response
63
	 */
64
	public function edit($id)
65
	{
66
		//return $id;
67
	}
68
69
70
	/**
71
	 * Update the specified resource in storage.
72
	 *
73
	 * @param  int  $id
74
	 * @return Response
75
	 */
76
	public function update($id)
77
	{
78
		$score = Input::get('score');
79
		$this->holeScore->update($id, $score);
80
	}
81
82
83
	/**
84
	 * Remove the specified resource from storage.
85
	 *
86
	 * @param  int  $id
87
	 * @return Response
88
	 */
89
	public function destroy($id)
90
	{
91
		//
92
	}
93
94
95
}
96