Completed
Push — master ( 0dfd17...a38508 )
by Sherif
02:04
created

DummyModel   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getCreatedAtAttribute() 4 4 1
A getUpdatedAtAttribute() 4 4 1
A getDeletedAtAttribute() 4 4 1
A boot() 5 5 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 namespace App\Modules\DummyModule;
2
3
use Illuminate\Database\Eloquent\Model;
4
use Illuminate\Database\Eloquent\SoftDeletes;
5
6 View Code Duplication
class DummyModel extends Model
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...
7
{
8
    use SoftDeletes;
9
    protected $table    = 'DummyTableName';
10
    protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
11
    protected $hidden   = ['deleted_at'];
12
    protected $guarded  = ['id'];
13
    protected $fillable = []; // Add attributes here
14
    public $searchable  = []; // Add earchable attributes here
15
    
16
    public function getCreatedAtAttribute($value)
17
    {
18
        return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
19
    }
20
21
    public function getUpdatedAtAttribute($value)
22
    {
23
        return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
24
    }
25
26
    public function getDeletedAtAttribute($value)
27
    {
28
        return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
29
    }
30
    
31
    public static function boot()
32
    {
33
        parent::boot();
34
        DummyModel::observe(\App::make('App\Modules\DummyModule\ModelObservers\DummyObserver'));
35
    }
36
}
37