EloquentPlayerRepository   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 0
dl 0
loc 33
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A all() 0 4 1
A find() 0 4 1
A create() 0 6 1
1
<?php namespace GolfLeague\Storage\Player;
2
3
use \Player as Player;
4
5
class EloquentPlayerRepository implements PlayerRepository
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
	public function __construct(Player $player)
15
    {
16
		$this->player = $player;
0 ignored issues
show
Bug introduced by
The property player does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
17
    }
18
19
    public function all()
20
    {
21
        return $this->player->orderBy('handicap','asc')->get();
22
    }
23
24
    //Find Player by Player Id
25
    public function find($playerId)
26
    {
27
        return $this->player->find($playerId);
28
    }
29
30
    public function create($name, $handicap)
31
    {
32
		$this->player->name = $name;
33
		$this->player->handicap = $handicap;
34
		$this->player->save();
35
    }
36
37
}
38