Completed
Push — develop ( f3c189...e92436 )
by Alejandro
08:55
created

AbstractMailListener   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A attach() 0 6 1
1
<?php
2
namespace AcMailer\Event;
3
4
use Zend\EventManager\AbstractListenerAggregate;
5
use Zend\EventManager\EventManagerInterface;
6
7
/**
8
 * Class AbstractMailListener
9
 * @author Alejandro Celaya Alastrué
10
 * @link http://www.alejandrocelaya.com
11
 */
12
abstract class AbstractMailListener extends AbstractListenerAggregate implements MailListenerInterface
13
{
14
    /**
15
     * @var \Zend\Stdlib\CallbackHandler[]
16
     */
17
    protected $listeners = [];
18
19
    /**
20
     * @param EventManagerInterface $events
21
     * @param int $priority
22
     */
23 4
    public function attach(EventManagerInterface $events, $priority = 1)
24
    {
25 4
        $this->listeners[] = $events->attach(MailEvent::EVENT_MAIL_PRE_SEND, [$this, 'onPreSend'], $priority);
26 4
        $this->listeners[] = $events->attach(MailEvent::EVENT_MAIL_POST_SEND, [$this, 'onPostSend'], $priority);
27 4
        $this->listeners[] = $events->attach(MailEvent::EVENT_MAIL_SEND_ERROR, [$this, 'onSendError'], $priority);
28 4
    }
29
}
30