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

AbstractMailListener::attach()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 6
ccs 5
cts 5
cp 1
rs 9.4285
cc 1
eloc 4
nc 1
nop 2
crap 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