EloquentHoleScoreRepository::update()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 4
nc 1
nop 2
1
<?php namespace GolfLeague\Storage\HoleScore;
2
3
use \Holescore as Holescore;
4
use \Player as Player;
5
6
class EloquentHoleScoreRepository implements HoleScoreRepository
7
{
8
  /*Return Score collections that include:
9
   * Player Name
10
   * Date
11
   * Total
12
   * Course
13
   * Multideminsional Array of Hole Numbers and scores
14
   **/
15
	public function __construct(Holescore $holescore)
16
    {
17
        $this->holescore = $holescore;
0 ignored issues
show
Bug introduced by
The property holescore 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...
18
    }
19
20
    public function all()
21
    {
22
        return $this->holescore->all();
23
    }
24
25
26
    public function find($id)
27
    {
28
        return Holescore::find($id);
29
    }
30
31
    public function create($input)
32
    {
33
        $this->holescore->create($input);
34
    }
35
36
	public function update($id, $score)
37
	{
38
		$holescore = $this->find($id);
39
		$holescore->score = $score;
40
		$holescore->save();
41
	}
42
43
	public function getByRound($roundId)
44
	{
45
		return $this->holescore->where('round_id', '=', $roundId)->orderBy('id', 'ASC')->get();
46
	}
47
}
48