Completed
Push — master ( df6768...08ae01 )
by Fèvre
11:28 queued 02:11
created

Permission   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 36
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 3
dl 36
loc 36
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A boot() 14 14 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
namespace Xetaravel\Models;
3
4
use Ultraware\Roles\Contracts\PermissionHasRelations as PermissionHasRelationsContract;
5
use Ultraware\Roles\Traits\PermissionHasRelations;
6
use Ultraware\Roles\Traits\Slugable;
7
8 View Code Duplication
class Permission extends Model implements PermissionHasRelationsContract
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
9
{
10
    use Slugable, PermissionHasRelations;
11
12
    /**
13
     * The attributes that are mass assignable.
14
     *
15
     * @var array
16
     */
17
    protected $fillable = [
18
        'name',
19
        'slug',
20
        'description',
21
        'model'
22
    ];
23
24
    /**
25
     * The "booting" method of the model.
26
     *
27
     * @return void
28
     */
29
    protected static function boot()
30
    {
31
        parent::boot();
32
33
        // Generated the slug before updating.
34
        static::updating(function ($model) {
35
            $model->setSlugAttribute($model->name);
36
        });
37
38
        // Generated the slug before creating.
39
        static::creating(function ($model) {
40
            $model->setSlugAttribute($model->name);
41
        });
42
    }
43
}
44