EloquentCtpRepository::findByMatch()   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 namespace GolfLeague\Storage\Ctp;
2
3
use \Ctp as Ctp;
4
5
class EloquentCtpRepository implements CtpRepository
6
{
7
  /*Return Score collections that include:
8
   * Player Name
9
   * Date
10
   * Total
11
   * Course
12
   * Multideminsional Array of Hole Numbers and scores   *
13
   **/
14
15
    public function all()
16
    {
17
        return Ctp::all();
18
    }
19
20
    public function find($id)
21
    {
22
        return Ctp::find($id);
23
    }
24
25
    //Find Ctps by Player Id
26
    public function findByPlayer($playerId)
27
    {
28
        return Ctp::with('player', 'hole', 'match')->where('player_id', '=', $playerId)->get();
29
    }
30
31
    public function findByHole($holeId)
32
    {
33
        return Ctp::with('player', 'hole')->where('hole_id', '=', $holeId)->get();
34
    }
35
36
    public function findByMatch($matchId)
37
    {
38
        return Ctp::with('player', 'hole')->where('match_id', '=', $matchId)->get();
39
    }
40
41
    public function create($input)
42
    {
43
        return Ctp::create($input);
44
    }
45
46
    //pass this a Ctp Eloquent object and replace it in database
47
    public function update($ctp)
48
    {
49
        $updateCtp = Ctp::find($ctp->id);
0 ignored issues
show
Unused Code introduced by
$updateCtp is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
50
        $updateCtp = $ctp;
51
        $updateCtp->save();
52
    }
53
}
54