Passed
Push — main ( ba4320...d07568 )
by Michael
03:19
created

DefinesModelRelations::couponables()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MichaelRubel\Couponables\Models\Traits;
6
7
use Illuminate\Database\Eloquent\Model;
8
use Illuminate\Database\Eloquent\Relations\HasMany;
9
use MichaelRubel\Couponables\Models\Contracts\CouponPivotContract;
10
11
trait DefinesModelRelations
12
{
13
    /**
14
     * Fetch the latest couponables - redeemed coupon records.
15
     *
16
     * @return HasMany
17
     */
18 1
    public function couponables(): HasMany
19
    {
20
        return $this
21 1
            ->hasMany(app(CouponPivotContract::class))
0 ignored issues
show
Bug introduced by
It seems like hasMany() 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

21
            ->/** @scrutinizer ignore-call */ hasMany(app(CouponPivotContract::class))
Loading history...
22 1
            ->latest();
23
    }
24
25
    /**
26
     * The only model allowed to redeem the coupon.
27
     *
28
     * @return Model|null
29
     */
30 2
    public function redeemer(): ?Model
31
    {
32 2
        return $this->morphTo()->first();
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

32
        return $this->/** @scrutinizer ignore-call */ morphTo()->first();
Loading history...
33
    }
34
}
35