ScoreService   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A update() 0 4 1
A __construct() 0 12 1
1
<?php namespace GolfLeague\Services;
2
3
use GolfLeague\Storage\Match\MatchRepository;
4
use GolfLeague\Storage\HoleScore\HoleScoreRepository as HoleScoreRepo;
5
use \Player;
6
use \Match;
7
use Illuminate\Events\Dispatcher;
8
9
/**
10
* ScoreService, containing all useful methods for business logic for scoring a round
11
*/
12
class ScoreService
13
{
14
15
    // Containing our matchRepository to make all our database calls
16
    protected $matchRepo;
17
18
    /**
19
    * Loads our $matchRepo
20
    *
21
    * @param MatchRepository $matchRepo
22
    * @return MatchService
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
23
    */
24
    public function __construct(MatchRepository $matchRepo,
25
                                HoleScoreRepo $holeScoreRepo,
26
                                Player $player,
27
                                Match $match,
28
                                Dispatcher $events)
29
    {
30
        $this->matchRepo = $matchRepo;
31
        $this->holeScoreRepo = $holeScoreRepo;
0 ignored issues
show
Bug introduced by
The property holeScoreRepo 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...
32
        $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...
33
        $this->match = $match;
0 ignored issues
show
Bug introduced by
The property match 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...
34
        $this->events = $events;
0 ignored issues
show
Bug introduced by
The property events 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...
35
    }
36
37
    public function update($id, $score)
38
    {
39
        $this->holeScoreRepo->update($id, $score);
40
    }
41
}
42