Playlist   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 66.67%

Importance

Changes 0
Metric Value
wmc 3
eloc 11
c 0
b 0
f 0
dl 0
loc 25
ccs 4
cts 6
cp 0.6667
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getIsSmartAttribute() 0 3 1
A user() 0 3 1
A songs() 0 3 1
1
<?php
2
3
namespace App\Models;
4
5
use App\Traits\CanFilterByUser;
6
use Illuminate\Database\Eloquent\Model;
7
use Illuminate\Database\Eloquent\Relations\BelongsTo;
8
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
9
use Illuminate\Support\Collection;
10
11
/**
12
 * @property int        $user_id
13
 * @property Collection $songs
14
 * @property int        $id
15
 * @property array      $rules
16
 * @property bool       $is_smart
17
 * @property string     $name
18
 * @property user       $user
19
 */
20
class Playlist extends Model
21
{
22
    use CanFilterByUser;
23
24
    protected $hidden = ['user_id', 'created_at', 'updated_at'];
25
    protected $guarded = ['id'];
26
    protected $casts = [
27
        'user_id' => 'int',
28
        'rules' => 'array',
29
    ];
30
    protected $appends = ['is_smart'];
31
32 3
    public function songs(): BelongsToMany
33
    {
34 3
        return $this->belongsToMany(Song::class);
35
    }
36
37
    public function user(): BelongsTo
38
    {
39
        return $this->belongsTo(User::class);
40
    }
41
42 4
    public function getIsSmartAttribute(): bool
43
    {
44 4
        return (bool) $this->rules;
45
    }
46
}
47