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

EventCreatedListener   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
lcom 1
cbo 3
dl 0
loc 21
rs 10
c 1
b 0
f 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A onEventCreated() 0 9 3
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
}