Match   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 110
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

6 Methods

Rating   Name   Duplication   Size   Complexity  
A tournament() 0 4 1
A homeTournamentTeam() 0 4 1
A awayTournamentTeam() 0 4 1
A getAvailableResultTypes() 0 11 1
A getAvailableGameTypes() 0 8 1
A getAvailableStatuses() 0 8 1
1
<?php
2
3
namespace App;
4
5
use Illuminate\Database\Eloquent\Model;
6
7
/**
8
 * Class Match
9
 * @package App
10
 */
11
class Match extends Model
12
{
13
    /**
14
     * @var string
15
     */
16
    protected $table = 'matches';
17
18
    /**
19
     * @var array
20
     */
21
    protected $fillable = [
22
        'tournamentId',
23
        'homeTournamentTeamId',
24
        'awayTournamentTeamId',
25
        'homeScore',
26
        'awayScore',
27
        'homePenaltyScore',
28
        'awayPenaltyScore',
29
        'gameType',
30
        'round',
31
        'resultType',
32
        'status',
33
    ];
34
35
    /**
36
     * @var bool
37
     */
38
    public $timestamps = true;
39
40
    const GAME_TYPE_GROUP_STAGE = 'group';
41
    const GAME_TYPE_QUALIFY = 'qualify';
42
    const GAME_TYPE_FINAL = 'final';
43
44
    const RESULT_TYPE_UNKNOWN = 'unknown';
45
    const RESULT_TYPE_HOME_WIN = 'home';
46
    const RESULT_TYPE_AWAY_WIN = 'away';
47
    const RESULT_TYPE_DRAW = 'draw';
48
    const RESULT_TYPE_HOME_PENALTY_WIN = 'home_penalty';
49
    const RESULT_TYPE_AWAY_PENALTY_WIN = 'away_penalty';
50
51
    const STATUS_STARTED = 'started';
52
    const STATUS_NOT_STARTED = 'not_started';
53
    const STATUS_FINISHED = 'finished';
54
55
    const POINTS_WIN = 3;
56
    const POINTS_DRAW = 1;
57
58
    /**
59
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
60
     */
61
    public function tournament()
62
    {
63
        return $this->belongsTo(Tournament::class, 'tournamentId');
64
    }
65
66
    /**
67
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
68
     */
69
    public function homeTournamentTeam()
70
    {
71
        return $this->belongsTo(TournamentTeam::class, 'homeTournamentTeamId');
72
    }
73
74
    /**
75
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
76
     */
77
    public function awayTournamentTeam()
78
    {
79
        return $this->belongsTo(TournamentTeam::class, 'awayTournamentTeamId');
80
    }
81
82
    /**
83
     * @return array
84
     */
85
    public static function getAvailableResultTypes()
86
    {
87
        return [
88
            self::RESULT_TYPE_UNKNOWN,
89
            self::RESULT_TYPE_HOME_WIN,
90
            self::RESULT_TYPE_AWAY_WIN,
91
            self::RESULT_TYPE_DRAW,
92
            self::RESULT_TYPE_HOME_PENALTY_WIN,
93
            self::RESULT_TYPE_AWAY_PENALTY_WIN,
94
        ];
95
    }
96
97
    /**
98
     * @return array
99
     */
100
    public static function getAvailableGameTypes()
101
    {
102
        return [
103
            self::GAME_TYPE_GROUP_STAGE,
104
            self::GAME_TYPE_QUALIFY,
105
            self::GAME_TYPE_FINAL,
106
        ];
107
    }
108
109
    /**
110
     * @return array
111
     */
112
    public static function getAvailableStatuses()
113
    {
114
        return [
115
            self::STATUS_STARTED,
116
            self::STATUS_NOT_STARTED,
117
            self::STATUS_FINISHED,
118
        ];
119
    }
120
}
121