Passed
Push — develop ( a95732...cd40df )
by Septianata
12:51
created

Relation   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 6
c 1
b 0
f 0
dl 0
loc 46
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A issuerable() 0 3 1
A getOrderRelationValue() 0 3 1
A setOrderRelationValue() 0 5 1
A order() 0 3 1
1
<?php
2
3
namespace App\Models\Concerns\OrderStatus;
4
5
use App\Models\Order;
6
use Illuminate\Database\Eloquent\Relations\BelongsTo;
7
use Illuminate\Database\Eloquent\Relations\MorphTo;
8
9
/**
10
 * @property int $order_id Foreign key of \App\Models\Order.
11
 * @property-read \App\Models\Order $order
12
 * @property string $issuerable_type
13
 * @property int $issuerable_id
14
 * @property-read \App\Models\Contracts\Issuerable $issuerable
15
 *
16
 * @see \App\Models\OrderStatus
17
 */
18
trait Relation
19
{
20
    /**
21
     * Define an inverse one-to-one or many relationship with \App\Models\Order.
22
     *
23
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
24
     */
25
    public function order(): BelongsTo
26
    {
27
        return $this->belongsTo(Order::class);
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

27
        return $this->/** @scrutinizer ignore-call */ belongsTo(Order::class);
Loading history...
28
    }
29
30
    /**
31
     * Return \App\Models\Order model relation value.
32
     *
33
     * @return \App\Models\Order
34
     */
35
    public function getOrderRelationValue(): Order
36
    {
37
        return $this->getRelationValue('order');
0 ignored issues
show
Bug introduced by
It seems like getRelationValue() 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

37
        return $this->/** @scrutinizer ignore-call */ getRelationValue('order');
Loading history...
38
    }
39
40
    /**
41
     * Set \App\Models\Order model relation value.
42
     *
43
     * @param  \App\Models\Order  $order
44
     * @return $this
45
     */
46
    public function setOrderRelationValue(Order $order)
47
    {
48
        $this->order()->associate($order);
49
50
        return $this;
51
    }
52
53
    /**
54
     * Define a polymorphic, inverse one-to-one or many relationship.
55
     *
56
     * @return \Illuminate\Database\Eloquent\Relations\MorphTo
57
     *
58
     * @see \App\Models\Customer
59
     * @see \App\Models\User
60
     */
61
    public function issuerable(): MorphTo
62
    {
63
        return $this->morphTo();
0 ignored issues
show
Bug introduced by
It seems like morphTo() 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

63
        return $this->/** @scrutinizer ignore-call */ morphTo();
Loading history...
64
    }
65
}
66