CarryOver   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
B calculate() 0 25 5
1
<?php namespace GolfLeague\Services;
2
3
use \Match;
4
use \Skin;
5
use \Level;
6
7
class CarryOver
8
{
9
10
    public function calculate()
11
    {
12
        $levels = Level::all();
13
        $matches = Match::all();
14
        $carryOverMoney = array();
15
        foreach ($levels as $key => $level){
16
            $carryOverMoney[$level->id] = 0;
17
            foreach($matches as $matchesKey => $match) {
18
                //check skins table for level and match
19
                $skins = Skin::where('match_id', '=', $match->id)->where('level_id', '=', $level->id)->get();
20
                if($skins->count() === 0 ) {
21
                    if ($level->id === 1){
22
                        $carryOverMoney[$level->id] += $match->skinsamoney;
23
                    }
24
                    else {
25
                        $carryOverMoney[$level->id] += $match->skinsbmoney;
26
                    }
27
                }
28
                else {
29
                    $carryOverMoney[$level->id] = 0; //reset carryover money
30
                }
31
            }
32
        }// End foreach
33
        return $carryOverMoney;
34
    }
35
}