HasPeriodicNotice   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 88.89%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 18
ccs 8
cts 9
cp 0.8889
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A periodicSentEntries() 0 3 1
A sendPeriodicalNotification() 0 6 1
A sendNowPeriodicalNotification() 0 3 1
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