ActionLog   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 46
Duplicated Lines 17.39 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 8
loc 46
ccs 0
cts 14
cp 0
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 6 1
A user() 8 8 2

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
/*
3
 * This file is part of the Laravel Platfourm package.
4
 *
5
 * (c) Avtandil Kikabidze aka LONGMAN <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Longman\Platfourm\Database\Eloquent\ActionLog;
12
13
use Longman\Platfourm\Database\Eloquent\Model;
14
use Longman\Platfourm\User\Models\Eloquent\User;
15
16
class ActionLog extends Model
17
{
18
19
    public $timestamps = false;
20
21
    /**
22
     * The database table used by the model.
23
     *
24
     * @var string
25
     */
26
    protected $table = 'action_log';
27
28
    /**
29
     * The attributes that are mass assignable.
30
     *
31
     * @var array
32
     */
33
    protected $fillable = [
34
        'user_id', 'lang', 'entity', 'scope', 'action', 'url', 'referer', 'before_data',
35
        'after_data', 'request_data', 'ip_address', 'user_agent'
36
    ];
37
38
    protected $casts = [
39
        'before_data' => 'array',
40
        'after_data' => 'array',
41
        'request_data' => 'array',
42
    ];
43
44
45
    public static function boot()
46
    {
47
        static::creating(function ($model) {
48
            $model->created_at = $model->freshTimestamp();
49
        });
50
    }
51
52 View Code Duplication
    public function user()
0 ignored issues
show
Duplication introduced by
This method 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...
53
    {
54
        $model = User::class;
55
        if (class_exists(\App\Models\User::class)) {
56
            $model = \App\Models\User::class;
57
        }
58
        return $this->hasOne($model);
59
    }
60
61
}
62