UsesRivetsTableTrait   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 9 1
A getTable() 0 4 1
A getMorphToSortableManyOtherKey() 0 4 1
A getType() 0 4 1
1
<?php
2
3
namespace Luminark\Rivet\Traits;
4
5
use Luminark\Rivet\Models\Scopes\RivetTypeScope;
6
7
trait UsesRivetsTableTrait
8
{
9
    public static function boot()
10
    {
11
        parent::boot();
12
13
        static::addGlobalScope(new RivetTypeScope(static::getType()));
14
        static::saving(function ($model) {
15
            $model->type = $model::getType();
16
        });
17
    }
18
19
    public function getTable()
20
    {
21
        return 'rivets';
22
    }
23
24
    public static function getMorphToSortableManyOtherKey()
25
    {
26
        return 'rivet_id';
27
    }
28
29
    protected static function getType()
30
    {
31
        return static::class;
32
    }
33
}
34