dev-think-one /
laravel-periodic-notice
| 1 | <?php |
||
| 2 | |||
| 3 | namespace PeriodicNotice\Notifications; |
||
| 4 | |||
| 5 | use Illuminate\Bus\Queueable; |
||
| 6 | use Illuminate\Contracts\Queue\ShouldQueue; |
||
| 7 | use Illuminate\Notifications\Notification; |
||
| 8 | use Illuminate\Support\Collection; |
||
| 9 | |||
| 10 | class PeriodicPublicationNotification extends Notification implements ShouldQueue |
||
| 11 | { |
||
| 12 | use Queueable; |
||
| 13 | use HasDynamicChannels { |
||
| 14 | HasDynamicChannels::via as dynamicVia; |
||
| 15 | } |
||
| 16 | |||
| 17 | 2 | public function __construct( |
|
| 18 | protected Collection $entities |
||
| 19 | ) { |
||
| 20 | 2 | } |
|
| 21 | |||
| 22 | 1 | public function via($notifiable) |
|
| 23 | { |
||
| 24 | 1 | if ($this->entities->count() > 0) { |
|
| 25 | 1 | return $this->dynamicVia($notifiable); |
|
| 26 | } |
||
| 27 | |||
| 28 | return []; |
||
| 29 | } |
||
| 30 | |||
| 31 | 1 | protected function mailMessageBuilder($notifiable): MailMessageBuilder |
|
|
0 ignored issues
–
show
|
|||
| 32 | { |
||
| 33 | 1 | $className = config('periodic-notice.defaults.mail_builder', MailMessageBuilder::class); |
|
| 34 | 1 | if (!is_a($className, MailMessageBuilder::class, true)) { |
|
| 35 | throw new \Exception('Wrong mail builder class'); |
||
| 36 | } |
||
| 37 | |||
| 38 | 1 | return $className::make(); |
|
| 39 | } |
||
| 40 | |||
| 41 | 1 | public function toMail($notifiable) |
|
| 42 | { |
||
| 43 | 1 | return $this->mailMessageBuilder($notifiable) |
|
| 44 | 1 | ->useEntries($this->entities) |
|
| 45 | 1 | ->build(); |
|
| 46 | } |
||
| 47 | } |
||
| 48 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.