Passed
Push — master ( b0c15d...be312e )
by Ruud
12:35
created

HasUserStamps::bootHasUserStamps()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Sqits\UserStamps\Concerns;
4
5
use Sqits\UserStamps\Observers\UserStampObserver;
6
7
trait HasUserStamps
8
{
9
    /**
10
     * Bootstrap the trait.
11
     *
12
     * @return void
13
     */
14
    public static function bootHasUserStamps()
15
    {
16
        static::observe(UserStampObserver::class);
17
    }
18
19
    /**
20
     * Get the user that created the model.
21
     *
22
     * @return Illuminate\Database\Eloquent\Relations\BelongsTo
0 ignored issues
show
Bug introduced by
The type Sqits\UserStamps\Concern...ent\Relations\BelongsTo was not found. Did you mean Illuminate\Database\Eloquent\Relations\BelongsTo? If so, make sure to prefix the type with \.
Loading history...
23
     */
24
    public function author()
25
    {
26
        return $this->belongsTo(
0 ignored issues
show
Bug introduced by
It seems like belongsTo() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

26
        return $this->/** @scrutinizer ignore-call */ belongsTo(
Loading history...
27
            config('userstamps.users_model'),
28
            config('userstamps.created_by_column')
29
        );
30
    }
31
32
    /**
33
     * Get the user that edited the model.
34
     *
35
     * @return Illuminate\Database\Eloquent\Relations\BelongsTo
36
     */
37
    public function editor()
38
    {
39
        return $this->belongsTo(
40
            config('userstamps.users_model'),
41
            config('userstamps.updated_by_column')
42
        );
43
    }
44
45
    /**
46
     * Get the user that deleted the model.
47
     *
48
     * @return Illuminate\Database\Eloquent\Relations\BelongsTo
49
     */
50
    public function destroyer()
51
    {
52
        return $this->belongsTo(
53
            config('userstamps.users_model'),
54
            config('userstamps.deleted_by_column')
55
        );
56
    }
57
58
    /**
59
     * Has the model loaded the SoftDeletes trait.
60
     *
61
     * @return bool
62
     */
63
    public function usingSoftDeletes()
64
    {
65
        return $usingSoftDeletes = in_array(
0 ignored issues
show
Unused Code introduced by
The assignment to $usingSoftDeletes is dead and can be removed.
Loading history...
66
            'Illuminate\Database\Eloquent\SoftDeletes',
67
            class_uses_recursive(
68
                get_called_class()
69
            )
70
        );
71
    }
72
}
73