Completed
Pull Request — master (#7)
by
unknown
02:28
created

EventCreatedListener::onEventCreated()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 0
loc 9
rs 9.6666
c 1
b 0
f 1
cc 3
eloc 5
nc 3
nop 1
1
<?php
2
3
namespace Azine\MailgunWebhooksBundle\EventListener;
4
5
use Azine\MailgunWebhooksBundle\Entity\MailgunWebhookEvent;
6
use Azine\MailgunWebhooksBundle\Services\AzineMailgunMailerService;
7
8
class EventCreatedListener
9
{
10
    private $mailer;
11
    private $sendNotifications;
12
    
13
    public function __construct(AzineMailgunMailerService $mailer, $sendNotifications)
14
    {
15
        $this->mailer = $mailer;   
16
        $this->sendNotifications = $sendNotifications;
17
    }
18
    
19
    public function onEventCreated(MailgunWebhookEvent $event)
20
    {
21
        $eventType = $event->getMailgunEvent()->getEvent();
22
        if ($eventType === 'complained') {
23
            if ($this->sendNotifications) {
24
                $this->mailer->sendSpamComplaintNotification($event->getMailgunEvent()->getId());                
25
            }
26
        }
27
    }
28
}