RoundHandler   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A handle() 0 15 2
A subscribe() 0 4 1
1
<?php
2
3
namespace GolfLeague\Handlers;
4
5
use GolfLeague\Storage\HoleScore\HoleScoreRepository;
6
use \Hole;
7
8
/**
9
 * MatchHandler Connection Class
10
 *
11
 * This class subscribes to events in related to match creation
12
 *
13
 * @author          Michael Schmidt
14
 */
15
class RoundHandler
16
{
17
    /**
18
     * Create a new instance of the MatchHandler
19
     *
20
     * @param  GolfLeague\Storage\Round\RoundRepository $roundRepo
0 ignored issues
show
Bug introduced by
There is no parameter named $roundRepo. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
21
     * @return void
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...
22
     */
23
    public function __construct(HoleScoreRepository $holescoreRepo)
24
    {
25
        $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...
26
    } // End of __construct
27
28
    /**
29
     * Create an initial round for each player after a new match is created
30
     *
31
     * @param  Match $match
0 ignored issues
show
Bug introduced by
There is no parameter named $match. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
32
     * @return void
33
     */
34
    public function handle($round)
35
    {
36
        $holes = Hole::where('course_id', '=', $round['course_id'])->get();
37
        foreach($holes as $hole){
38
            $input = array(
39
                'score' => null,
40
                'hole_id' => $hole->id,
41
                'round_id' => $round['id']
42
            );
43
            $this->holescoreRepo->create($input);
44
        }
45
46
47
48
    }
49
50
    /**
51
     * Register the listeners for the subscriber.
52
     *
53
     * @param  Illuminate\Events\Dispatcher $events
54
     * @return array
55
     */
56
    public function subscribe($events)
57
    {
58
        $events->listen('eloquent.created: Round', 'GolfLeague\Handlers\RoundHandler');
59
    }
60
}
61