AbstractMailListener   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 43
c 0
b 0
f 0
rs 10
ccs 5
cts 5
cp 1

4 Methods

Rating   Name   Duplication   Size   Complexity  
A attach() 0 6 1
A onPreSend() 0 4 1
A onPostSend() 0 4 1
A onSendError() 0 4 1
1
<?php
2
declare(strict_types=1);
3
4
namespace AcMailer\Event;
5
6
use Zend\EventManager\AbstractListenerAggregate;
7
use Zend\EventManager\EventManagerInterface;
8
9
/**
10
 * Class AbstractMailListener
11
 * @author Alejandro Celaya Alastrué
12
 * @link http://www.alejandrocelaya.com
13
 */
14
abstract class AbstractMailListener extends AbstractListenerAggregate implements MailListenerInterface
15
{
16
    /**
17
     * @param EventManagerInterface $events
18
     * @param int $priority
19
     */
20
    public function attach(EventManagerInterface $events, $priority = 1)
21
    {
22
        $this->listeners[] = $events->attach(MailEvent::EVENT_MAIL_PRE_SEND, [$this, 'onPreSend'], $priority);
23 4
        $this->listeners[] = $events->attach(MailEvent::EVENT_MAIL_POST_SEND, [$this, 'onPostSend'], $priority);
24
        $this->listeners[] = $events->attach(MailEvent::EVENT_MAIL_SEND_ERROR, [$this, 'onSendError'], $priority);
25 4
    }
26 4
27 4
    /**
28 4
     * Called before sending the email
29
     * @param MailEvent $e
30
     * @return mixed
31
     */
32
    public function onPreSend(MailEvent $e)
33
    {
34
        // TODO: Implement onPreSend() method.
35
    }
36
37
    /**
38
     * Called after sending the email
39
     * @param MailEvent $e
40
     * @return mixed
41
     */
42
    public function onPostSend(MailEvent $e)
43
    {
44
        // TODO: Implement onPostSend() method.
45
    }
46
47
    /**
48
     * Called if an error occurs while sending the email
49
     * @param MailEvent $e
50
     * @return mixed
51
     */
52
    public function onSendError(MailEvent $e)
53
    {
54
        // TODO: Implement onSendError() method.
55
    }
56
}
57