MoneyService   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A totalMatchMoney() 0 10 1
1
<?php namespace GolfLeague\Services;
2
3
use GolfLeague\Storage\Match\MatchRepository;
4
use \Match;
5
use \Ctp;
6
use \Grosswinner;
7
use \Netwinner;
8
use \Skin;
9
10
use Illuminate\Events\Dispatcher;
11
12
/**
13
* MoneyService, containing all useful methods for business logic for money relating to a match
14
*/
15
class MoneyService
16
{
17
18
    // Containing our matchRepository to make all our database calls
19
    protected $matchRepo;
20
21
    /**
22
    * Loads our $matchRepo
23
    *
24
    * @param MatchRepository $matchRepo
0 ignored issues
show
Bug introduced by
There is no parameter named $matchRepo. 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...
25
    * @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...
26
    */
27
    public function __construct()
28
    {
29
30
    }
31
32
    public function totalMatchMoney($matchId)
33
    {
34
        //get player id and money for ctp
35
        $results['ctps'] =  Ctp::with('player')->where('match_id', '=', $matchId)->get();
0 ignored issues
show
Coding Style Comprehensibility introduced by
$results was never initialized. Although not strictly required by PHP, it is generally a good practice to add $results = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
36
        $results['skins'] = Skin::with('player', 'hole')->where('match_id', '=', $matchId)->get();
37
        $results['netwinner'] = Netwinner::with('player')->where('match_id', '=', $matchId)->get();
38
        $results['grosswinner'] = Grosswinner::with('player')->where('match_id', '=', $matchId)->get();
39
        $results['moneylist'] = Match::with('players')->where('id', '=', $matchId)->get();
40
		return $results;
41
    }
42
}
43