Passed
Push — master ( de2a89...024236 )
by Julien
04:22
created

Team   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A competitors() 0 4 1
A getNameAttribute() 0 4 2
A hasAttribute() 0 4 1
1
<?php
2
3
namespace Xoco70\LaravelTournaments\Models;
4
5
class Team extends Fighter
6
{
7
    protected $table = 'team';
8
    public $timestamps = true;
9
    protected $fillable = ['short_id', 'name', 'championship_id'];
10
11
12
13
14
    public function competitors()
15
    {
16
        return $this->belongsToMany(Competitor::class)->withTimestamps();
17
    }
18
19
    /**
20
     * Get Team Name
21
     * @return mixed|string
22
     */
23
    public function getNameAttribute()
24
    {
25
        return ($this->hasAttribute('name')) ? $this->attributes['name'] : "";
26
    }
27
    public function hasAttribute($attr)
28
    {
29
        return array_key_exists($attr, $this->attributes);
30
    }
31
}
32