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

MorphToIssuerable::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 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
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\Support\Relation;
4
5
use App\Models\Contracts\Issuerable;
6
use Illuminate\Database\Eloquent\Relations\MorphTo;
7
8
/**
9
 * @property string $issuerable_type
10
 * @property int $issuerable_id
11
 * @property-read \App\Models\Contracts\Issuerable $issuerable
12
 */
13
trait MorphToIssuerable
14
{
15
    /**
16
     * Define a polymorphic, inverse one-to-one or many relationship with model that implements \App\Models\Contracts\Issuerable.
17
     *
18
     * @return \Illuminate\Database\Eloquent\Relations\MorphTo
19
     *
20
     * @see \App\Models\Customer
21
     * @see \App\Models\User
22
     */
23 4
    public function issuerable(): MorphTo
24
    {
25 4
        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

25
        return $this->/** @scrutinizer ignore-call */ morphTo();
Loading history...
26
    }
27
28
    /**
29
     * Return \App\Models\Issuerable model relation value.
30
     *
31
     * @return \App\Models\Contracts\Issuerable
32
     */
33
    public function getIssuerableRelationValue(): Issuerable
34
    {
35
        return $this->getRelationValue('issuerable');
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

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