Passed
Pull Request — master (#616)
by Mathias
10:37
created

SendMailStrategy::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 1
c 1
b 0
f 1
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
/**
4
 * YAWIK
5
 *
6
 * @see       https://github.com/cross-solution/YAWIK for the canonical source repository
7
 * @copyright https://github.com/cross-solution/YAWIK/blob/master/COPYRIGHT
8
 * @license   https://github.com/cross-solution/YAWIK/blob/master/LICENSE
9
 */
10
11
declare(strict_types=1);
12
13
namespace Core\Queue\Strategy;
14
15
use Core\Mail\MailService;
16
use Laminas\EventManager\EventManagerInterface;
17
use SlmQueue\Strategy\AbstractStrategy;
18
use SlmQueue\Worker\Event\AbstractWorkerEvent;
19
20
/**
21
 * TODO: description
22
 *
23
 * @author Mathias Gelhausen
24
 * TODO: write tests
25
 */
26
class SendMailStrategy extends AbstractStrategy
27
{
28
    private $mailService;
29
30
    public function __construct(MailService $mailService)
31
    {
32
        $this->mailService = $mailService;
33
    }
34
35
    /**
36
     * Registers itself with an EventManager
37
     *
38
     * @param EventManagerInterface $events
39
     * @param int                   $priority
40
     */
41
    public function attach(EventManagerInterface $events, $priority = 1) : void
42
    {
43
        $this->listeners[] = $events->attach(AbstractWorkerEvent::EVENT_PROCESS_JOB, [$this, 'logJobStart'], 1000);
0 ignored issues
show
Bug Best Practice introduced by
The property listeners does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
44
        $this->listeners[] = $events->attach(AbstractWorkerEvent::EVENT_PROCESS_JOB, [$this, 'logJobEnd'], -1000);
45
        $this->listeners[] = $events->attach(AbstractWorkerEvent::EVENT_PROCESS_IDLE, [$this, 'injectLoggerInEvent'], 1000);
46
        $this->listeners[] = $events->attach(AbstractWorkerEvent::EVENT_PROCESS_STATE, [$this, 'injectLoggerInEvent'], 1000);
47
    }
48
}
49