Rivet   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 11 2
A getSerializableAttributes() 0 4 1
A getMorphToManyName() 0 4 1
A getMorphToSortableManyOtherKey() 0 4 1
1
<?php
2
3
namespace Luminark\Rivet\Models;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Luminark\SerializableValues\Traits\HasSerializableValuesTrait;
7
use Luminark\Rivet\Models\Scopes\RivetTypeScope;
8
use Illuminate\Support\Str;
9
10
/**
11
 * @property string type
12
 * @property array values
13
 * @property stdClass file
14
 */
15
class Rivet extends Model
16
{
17
    use HasSerializableValuesTrait;
18
19
    public static function boot()
20
    {
21
        parent::boot();
22
23
        if (static::class == Rivet::class) {
24
            static::addGlobalScope(new RivetTypeScope(static::class));
25
            static::saving(function ($model) {
26
                $model->type = static::class;
27
            });
28
        }
29
    }
30
31
    protected $fillable = ['values'];
32
33
    protected function getSerializableAttributes()
34
    {
35
        return ['file'];
36
    }
37
38
    public static function getMorphToManyName()
39
    {
40
        return 'rivetable';
41
    }
42
43
    public static function getMorphToSortableManyOtherKey()
44
    {
45
        return null;
46
    }
47
}
48