Passed
Push — develop ( 6dcea6...5ae9a6 )
by Septianata
16:24
created

Relation::getIssuerableRelationValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace App\Models\Concerns\OrderStatus;
4
5
use App\Models\Order;
6
use App\Models\Support\Relation\MorphToIssuerable;
7
use Illuminate\Database\Eloquent\Relations\BelongsTo;
8
9
/**
10
 * @property int $order_id Foreign key of \App\Models\Order.
11
 * @property-read \App\Models\Order $order
12
 *
13
 * @see \App\Models\OrderStatus
14
 */
15
trait Relation
16
{
17
    use MorphToIssuerable;
18
19
    /**
20
     * Define an inverse one-to-one or many relationship with \App\Models\Order.
21
     *
22
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
23
     */
24
    public function order(): BelongsTo
25
    {
26
        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

26
        return $this->/** @scrutinizer ignore-call */ belongsTo(Order::class);
Loading history...
27
    }
28
29
    /**
30
     * Return \App\Models\Order model relation value.
31
     *
32
     * @return \App\Models\Order
33
     */
34
    public function getOrderRelationValue(): Order
35
    {
36
        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

36
        return $this->/** @scrutinizer ignore-call */ getRelationValue('order');
Loading history...
37
    }
38
39
    /**
40
     * Set \App\Models\Order model relation value.
41
     *
42
     * @param  \App\Models\Order  $order
43
     * @return $this
44
     */
45
    public function setOrderRelationValue(Order $order)
46
    {
47
        $this->order()->associate($order);
48
49
        return $this;
50
    }
51
}
52