SoftDeletesBy::softDeletesByMorph()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Reedware\LaravelBlueprints\Concerns;
4
5
trait SoftDeletesBy
6
{
7
    /**
8
     * Alias of {@see $this->deletedBy()}.
9
     *
10
     * @param  string       $table
11
     * @param  string|null  $local
12
     * @param  string|null  $name
13
     * @param  string|null  $onUpdate
14
     * @param  string|null  $onDelete
15
     *
16
     * @return \Illuminate\Support\Fluent
17
     */
18
    public function softDeletesBy($table = null, $local = null, $name = null, $onUpdate = null, $onDelete = null)
19
    {
20
    	return $this->deletedBy($table, $local, $name, $onUpdate, $onDelete);
21
    }
22
23
    /**
24
     * Alias of {@see $this->deletedByMorph()}.
25
     *
26
     * @param  string|null  $indexName
27
     *
28
     * @return \Illuminate\Support\Fluent
29
     */
30
    public function softDeletesByMorph($indexName = null)
31
    {
32
        return $this->deletedByMorph($indexName);
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->deletedByMorph($indexName) targeting Reedware\LaravelBlueprin...tesBy::deletedByMorph() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
Bug Best Practice introduced by
The expression return $this->deletedByMorph($indexName) returns the type void which is incompatible with the documented return type Illuminate\Support\Fluent.
Loading history...
33
    }
34
35
    /**
36
     * Alias of {@see $this->bigDeletedBy()}.
37
     *
38
     * @param  string       $table
39
     * @param  string|null  $local
40
     * @param  string|null  $name
41
     * @param  string|null  $onUpdate
42
     * @param  string|null  $onDelete
43
     *
44
     * @return \Illuminate\Support\Fluent
45
     */
46
    public function bigSoftDeletesBy($table = null, $local = null, $name = null, $onUpdate = null, $onDelete = null)
47
    {
48
        return $this->bigDeletedBy($table, $local, $name, $onUpdate, $onDelete);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->bigDeleted..., $onUpdate, $onDelete) returns the type void which is incompatible with the documented return type Illuminate\Support\Fluent.
Loading history...
Bug introduced by
Are you sure the usage of $this->bigDeletedBy($tab..., $onUpdate, $onDelete) targeting Reedware\LaravelBlueprin...letesBy::bigDeletedBy() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
49
    }
50
51
    /**
52
     * Alias of {@see $this->bigDeletedByMorph()}.
53
     *
54
     * @param  string|null  $indexName
55
     *
56
     * @return \Illuminate\Support\Fluent
57
     */
58
    public function bigSoftDeletesByMorph($indexName = null)
59
    {
60
        return $this->bigDeletedByMorph($indexName);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->bigDeletedByMorph($indexName) returns the type void which is incompatible with the documented return type Illuminate\Support\Fluent.
Loading history...
Bug introduced by
Are you sure the usage of $this->bigDeletedByMorph($indexName) targeting Reedware\LaravelBlueprin...By::bigDeletedByMorph() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
61
    }
62
63
    /**
64
     * Adds the 'deleted_by_id' Reference.
65
     *
66
     * @param  string       $table
67
     * @param  string|null  $local
68
     * @param  string|null  $name
69
     * @param  string|null  $onUpdate
70
     * @param  string|null  $onDelete
71
     *
72
     * @return \Illuminate\Support\Fluent
73
     */
74
    public function deletedBy($table = null, $local = null, $name = null, $onUpdate = null, $onDelete = null)
75
    {
76
        // Determine the Table
77
        if(is_null($table)) {
78
            $table = $this->getTimestampsByTable();
0 ignored issues
show
Bug introduced by
It seems like getTimestampsByTable() 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

78
            /** @scrutinizer ignore-call */ 
79
            $table = $this->getTimestampsByTable();
Loading history...
79
        }
80
81
        // Create the Belongs to Relation
82
    	return $this->belongsTo($table, 'deleted_by_id', $local, $name, $onUpdate, $onDelete)->nullable();
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

82
    	return $this->/** @scrutinizer ignore-call */ belongsTo($table, 'deleted_by_id', $local, $name, $onUpdate, $onDelete)->nullable();
Loading history...
83
    }
84
85
    /**
86
     * Adds the 'deleted_by_id' Morph Reference.
87
     *
88
     * @param  string|null  $indexName
89
     *
90
     * @return void
91
     */
92
    public function deletedByMorph($indexName = null)
93
    {
94
        // Create the 'deleted_by_id' Morph Column
95
        $this->belongsToColumn('deleted_by_id')->nullable();
0 ignored issues
show
Bug introduced by
It seems like belongsToColumn() 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

95
        $this->/** @scrutinizer ignore-call */ 
96
               belongsToColumn('deleted_by_id')->nullable();
Loading history...
96
97
        // Create the 'deleted_by_type' Morph Column
98
        $this->string('deleted_by_type', 255)->nullable();
0 ignored issues
show
Bug introduced by
It seems like string() 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

98
        $this->/** @scrutinizer ignore-call */ 
99
               string('deleted_by_type', 255)->nullable();
Loading history...
99
100
        // Index the two Columns
101
        $this->index(['deleted_by_id', 'deleted_by_type'], $indexName);
0 ignored issues
show
Bug introduced by
It seems like index() 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

101
        $this->/** @scrutinizer ignore-call */ 
102
               index(['deleted_by_id', 'deleted_by_type'], $indexName);
Loading history...
102
    }
103
104
    /**
105
     * Adds the 'deleted_by_id' Reference.
106
     *
107
     * @param  string       $table
108
     * @param  string|null  $local
109
     * @param  string|null  $name
110
     * @param  string|null  $onUpdate
111
     * @param  string|null  $onDelete
112
     *
113
     * @return void
114
     */
115
    public function bigDeletedBy($table = null, $local = null, $name = null, $onUpdate = null, $onDelete = null)
116
    {
117
        // Determine the Table
118
        if(is_null($table)) {
119
            $table = $this->getTimestampsByTable();
120
        }
121
122
        // Create the Belongs to Relation
123
        return $this->bigBelongsTo($table, 'deleted_by_id', $local, $name, $onUpdate, $onDelete)->nullable();
0 ignored issues
show
Bug introduced by
It seems like bigBelongsTo() 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

123
        return $this->/** @scrutinizer ignore-call */ bigBelongsTo($table, 'deleted_by_id', $local, $name, $onUpdate, $onDelete)->nullable();
Loading history...
124
    }
125
126
    /**
127
     * Adds the 'deleted_by_id' Morph Reference.
128
     *
129
     * @param  string|null  $indexName
130
     *
131
     * @return void
132
     */
133
    public function bigDeletedByMorph($indexName = null)
134
    {
135
        // Create the 'deleted_by_id' Morph Column
136
        $this->bigBelongsToColumn('deleted_by_id')->nullable();
0 ignored issues
show
Bug introduced by
It seems like bigBelongsToColumn() 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

136
        $this->/** @scrutinizer ignore-call */ 
137
               bigBelongsToColumn('deleted_by_id')->nullable();
Loading history...
137
138
        // Create the 'deleted_by_type' Morph Column
139
        $this->string('deleted_by_type', 255)->nullable();
140
141
        // Index the two Columns
142
        $this->index(['deleted_by_id', 'deleted_by_type'], $indexName);
143
    }
144
}