HasPeriodicNotice::sendPeriodicalNotification()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1.008

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 6
ccs 4
cts 5
cp 0.8
crap 1.008
rs 10
1
<?php
2
3
namespace PeriodicNotice\Concerns;
4
5
use Illuminate\Database\Eloquent\Relations\MorphMany;
6
use PeriodicNotice\Models\PeriodicSentEntry;
7
8
/**
9
 * Trait related to notification receiver.
10
 *
11
 * @mixin \PeriodicNotice\Contracts\NotificationReceiver
12
 * @mixin \Illuminate\Database\Eloquent\Model
13
 */
14
trait HasPeriodicNotice
15
{
16 1
    public function periodicSentEntries(): MorphMany
17
    {
18 1
        return $this->morphMany(PeriodicSentEntry::class, 'receiver');
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

18
        return $this->/** @scrutinizer ignore-call */ morphMany(PeriodicSentEntry::class, 'receiver');
Loading history...
19
    }
20
21 1
    public function sendNowPeriodicalNotification(string $group = 'default')
22
    {
23 1
        $this->periodicNoticeDirector($group)->sendPeriodicalNotification($this);
0 ignored issues
show
Bug introduced by
It seems like periodicNoticeDirector() 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

23
        $this->/** @scrutinizer ignore-call */ 
24
               periodicNoticeDirector($group)->sendPeriodicalNotification($this);
Loading history...
24
    }
25
26 1
    public function sendPeriodicalNotification(string $group = 'default')
27
    {
28 1
        dispatch(function () use ($group) {
29
            $this->sendNowPeriodicalNotification($group);
30 1
        })->onConnection(config('periodic-notice.defaults.connection'))
31 1
          ->onQueue(config('periodic-notice.defaults.queue'));
32
    }
33
}
34