EloquentTeamRepository::findByYear()   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\Team;
2
3
use \Team as Team;
4
5
class EloquentTeamRepository implements TeamRepository
6
{
7
    private $team;
8
9
    public function __construct(Team $team)
10
    {
11
        $this->team = $team;
12
    }
13
14
    public function all()
15
    {
16
        return $this->team->all();
17
    }
18
    public function findById($id)
19
    {
20
        return $this->team->where('id', '=', $id)->get();
21
    }
22
23
    public function findByYear($year)
24
    {
25
        return $this->team->whereYear('created_at', '=', $year)->get();
26
    }
27
28
    public function create($input)
29
    {
30
        $this->team->create($input);
31
    }
32
33
    public function update($team)
34
    {
35
        $updateTeam = $this->team->where('id', '=', $id)->get();
0 ignored issues
show
Bug introduced by
The variable $id does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
Unused Code introduced by
$updateTeam 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...
36
        $updateTeam = $team;
37
        $updateTeam->save();
38
    }
39
40
}