Logs   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 55
Duplicated Lines 32.73 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 8
c 3
b 0
f 1
lcom 0
cbo 2
dl 18
loc 55
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getCreatedByAttribute() 9 9 4
A getTargetAttribute() 9 9 4

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 jlourenco\base\Models;
2
3
use Illuminate\Database\Eloquent\Model;
4
use jlourenco\base\Repositories\LogRepositoryInterface;
5
use jlourenco\support\Traits\Creation;
6
use Sentinel;
7
8
class Logs extends Model
9
{
10
11
    /**
12
     * To allow user actions identity (Created_by, Updated_by, Deleted_by)
13
     */
14
    use Creation;
15
16
    /**
17
     * {@inheritDoc}
18
     */
19
    protected $table = 'Logs';
20
21
    /**
22
     * {@inheritDoc}
23
     */
24
    protected $fillable = [
25
        'log',
26
        'target',
27
        'ip',
28
    ];
29
30
    /**
31
     * Get the user's first name.
32
     *
33
     * @param  string  $value
34
     * @return string
35
     */
36 View Code Duplication
    public function getCreatedByAttribute($value)
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...
37
    {
38
        if ($value > 0)
39
            if ($user = Sentinel::findUserById($value))
40
                if ($user != null)
41
                    return $user->first_name . ' ' . $user->last_name . ' (ID: ' . $user->id . ')';
42
43
        return $value;
44
    }
45
46
    /**
47
     * Get the user's first name.
48
     *
49
     * @param  string  $value
50
     * @return string
51
     */
52 View Code Duplication
    public function getTargetAttribute($value)
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
        if ($value > 0)
55
            if ($user = Sentinel::findUserById($value))
56
                if ($user != null)
57
                    return $user->first_name . ' ' . $user->last_name . ' (ID: ' . $user->id . ')';
58
59
        return $value;
60
    }
61
62
}