EloquentTeamRepository   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 0
dl 0
loc 36
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A all() 0 4 1
A findById() 0 4 1
A findByYear() 0 4 1
A create() 0 4 1
A update() 0 6 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
}