TournamentService   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 2
dl 0
loc 31
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 10 2
A getByMatchId() 0 9 1
A get() 0 5 1
1
<?php
2
3
namespace GolfLeague\Tournament;
4
5
use \Tournament as Tournament;
6
use \Tournamentdate as Tournamentdate;
7
use Match as Match;
8
9
class TournamentService
10
{
11
12
    public function create($input)
13
    {
14
        $tournament = new Tournament($input);
15
        $tournament->save();
16
17
        foreach ($input['dates'] as $date){
18
            $tournamentDate = new Tournamentdate(array('date' => $date));
19
            $tournament->dates()->save($tournamentDate);
20
        }
21
    }
22
23
    public function getByMatchId($id)
24
    {
25
        //Get Match date and check tournament table for a tournament on that date
26
        $match = Match::find($id);
27
        $date = $match->date;
28
        
29
        $tournamentDate = Tournamentdate::select('tournament_id')->where('date', '=', $date)->get();
30
        return $tournamentDate;
31
    }
32
33
    public function get($id)
34
    {
35
        $tournament = Tournament::find($id);
36
        return $tournament;
37
    }
38
39
}