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

Relation::setDenominationRelationValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 5
ccs 0
cts 3
cp 0
rs 10
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
namespace App\Models\Concerns\Item;
4
5
use App\Models\Denomination;
6
use App\Models\Order;
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
 * @property int $denomination_id Foreign key of \App\Models\Denomination.
13
 * @property-read \App\Models\Denomination $denomination
14
 *
15
 * @see \App\Models\Item
16
 */
17
trait Relation
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
    /**
53
     * Define an inverse one-to-one or many relationship with \App\Models\Denomination.
54
     *
55
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
56
     */
57 2
    public function denomination(): BelongsTo
58
    {
59 2
        return $this->belongsTo(Denomination::class);
60
    }
61
62
    /**
63
     * Return \App\Models\Denomination model relation value.
64
     *
65
     * @return \App\Models\Denomination
66
     */
67 2
    public function getDenominationRelationValue(): Denomination
68
    {
69 2
        return $this->getRelationValue('denomination');
70
    }
71
72
    /**
73
     * Set \App\Models\Denomination model relation value.
74
     *
75
     * @param  \App\Models\Denomination  $denomination
76
     * @return $this
77
     */
78
    public function setDenominationRelationValue(Denomination $denomination)
79
    {
80
        $this->denomination()->associate($denomination);
81
82
        return $this;
83
    }
84
}
85