Passed
Push — master ( dd3a40...b9ffdf )
by Hirofumi
07:38
created

SendUnsentNotificationsHandler   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 4
dl 0
loc 36
ccs 0
cts 15
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A handle() 0 8 2
1
<?php
2
3
namespace Shippinno\Notification\Application\Command;
4
5
use Shippinno\Notification\Domain\Model\GatewayRegistry;
6
use Shippinno\Notification\Domain\Model\NotificationRepository;
7
8
class SendUnsentNotificationsHandler
9
{
10
    /**
11
     * @var NotificationRepository
12
     */
13
    private $notificationRepository;
14
15
    /**
16
     * @var GatewayRegistry
17
     */
18
    private $gatewayRegistry;
19
20
    /**
21
     * @param NotificationRepository $notificationRepository
22
     * @param GatewayRegistry $gatewayRegistry
23
     */
24
    public function __construct(
25
        NotificationRepository $notificationRepository,
26
        GatewayRegistry $gatewayRegistry
27
    ) {
28
        $this->notificationRepository = $notificationRepository;
29
        $this->gatewayRegistry = $gatewayRegistry;
30
    }
31
32
    /**
33
     * @param SendUnsentNotifications $command
34
     */
35
    public function handle(SendUnsentNotifications $command): void
1 ignored issue
show
Unused Code introduced by
The parameter $command is not used and could be removed.

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

Loading history...
36
    {
37
        $notifications = $this->notificationRepository->unsentNotifications();
38
        foreach ($notifications as $notification) {
39
            $this->gatewayRegistry->get($notification->destination())->send($notification);
40
            $notification->markSent();
41
        }
42
    }
43
}
44