InPeriodicNotice::notificationEntityWebUrl()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
namespace PeriodicNotice\Concerns;
4
5
use Illuminate\Database\Eloquent\Builder;
6
use Illuminate\Database\Eloquent\Model;
7
use Illuminate\Database\Eloquent\Relations\MorphMany;
8
use PeriodicNotice\Models\PeriodicSentEntry;
9
10
/**
11
 * Trait related to sendable entity.
12
 */
13
trait InPeriodicNotice
14
{
15 1
    public function notificationEntityTitle(): string
16
    {
17 1
        return $this->title ?? '';
18
    }
19
20 1
    public function notificationEntityWebUrl(): string
21
    {
22 1
        return url($this->slug ?? '');
23
    }
24
25 1
    public function notificationEntityDescription(): string
26
    {
27 1
        return $this->description ?? '';
28
    }
29
30 2
    public function periodicSentEntries(): MorphMany
31
    {
32 2
        return $this->morphMany(PeriodicSentEntry::class, 'sendable');
0 ignored issues
show
Bug introduced by
It seems like morphMany() 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 */ morphMany(PeriodicSentEntry::class, 'sendable');
Loading history...
33
    }
34
35 2
    public function scopeDoesntSentInPeriodicNotice(Builder $query, Model $receiver, string $group)
36
    {
37 2
        $query->whereDoesntHave(
38 2
            'periodicSentEntries',
39 2
            function (Builder $query) use ($receiver, $group) {
40 2
                $query->group($group)
41 2
                      ->where('receiver_type', '=', $receiver->getMorphClass())
42 2
                      ->where('receiver_id', '=', $receiver->getKey());
43 2
            }
44 2
        );
45
    }
46
47
    public function scopeReleasedAfter(Builder $query, \DateTimeInterface|string $dateTime, string $group)
0 ignored issues
show
Unused Code introduced by
The parameter $group is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

47
    public function scopeReleasedAfter(Builder $query, \DateTimeInterface|string $dateTime, /** @scrutinizer ignore-unused */ string $group)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
48
    {
49
        $query->where('created_at', '>=', $dateTime);
50
    }
51
}
52