SingleSender::send()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Fenos\Notifynder\Senders;
4
5
use Fenos\Notifynder\Models\Notification;
6
use Fenos\Notifynder\Contracts\SenderContract;
7
use Fenos\Notifynder\Contracts\SenderManagerContract;
8
9
/**
10
 * Class SingleSender.
11
 */
12
class SingleSender implements SenderContract
13
{
14
    /**
15
     * @var \Fenos\Notifynder\Builder\Notification
16
     */
17
    protected $notification;
18
19
    /**
20
     * SingleSender constructor.
21
     *
22
     * @param array $notifications
23
     */
24
    public function __construct(array $notifications)
25
    {
26
        $this->notification = array_values($notifications)[0];
27
    }
28
29
    /**
30
     * Send the single notification.
31
     *
32
     * @param SenderManagerContract $sender
33
     * @return bool
34
     */
35
    public function send(SenderManagerContract $sender)
36
    {
37
        $model = app('notifynder.resolver.model')->getModel(Notification::class);
38
39
        $notification = new $model($this->notification);
40
41
        return $notification->save();
42
    }
43
}
44