AbstractMessageStrategy   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 8
c 0
b 0
f 0
lcom 1
cbo 1
dl 0
loc 52
rs 10

9 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A success() 0 4 1
A error() 0 4 1
A getEventDispatcher() 0 4 1
A setEventDispatcher() 0 4 1
A getMessage() 0 4 1
A setMessage() 0 4 1
A on() 0 4 1
execute() 0 1 ?
1
<?php
2
namespace AramisAuto\EmailController\MessageStrategy;
3
4
use AramisAuto\EmailController\Message;
5
use Psr\Log\LoggerAwareInterface;
6
use Psr\Log\LoggerAwareTrait;
7
use Symfony\Component\EventDispatcher\EventDispatcher;
8
9
abstract class AbstractMessageStrategy implements LoggerAwareInterface
10
{
11
    use LoggerAwareTrait;
12
13
    private $eventDispatcher;
14
    private $eventError;
15
    private $eventSuccess;
16
    private $message;
17
18
    public function __construct()
19
    {
20
        $this->eventError = sprintf('emailcontroller.%s.error', uniqid());
21
        $this->eventSuccess = sprintf('emailcontroller.%s.success', uniqid());
22
    }
23
24
    public function success()
25
    {
26
        return $this->eventSuccess;
27
    }
28
29
    public function error()
30
    {
31
        return $this->eventError;
32
    }
33
34
    public function getEventDispatcher()
35
    {
36
        return $this->eventDispatcher;
37
    }
38
39
    public function setEventDispatcher(EventDispatcher $eventDispatcher)
40
    {
41
        $this->eventDispatcher = $eventDispatcher;
42
    }
43
44
    public function getMessage()
45
    {
46
        return $this->message;
47
    }
48
49
    public function setMessage(Message $message)
50
    {
51
        $this->message = $message;
52
    }
53
54
    public function on($eventName, $callback)
55
    {
56
        $this->getEventDispatcher()->addListener($eventName, $callback);
57
    }
58
59
    abstract public function execute();
0 ignored issues
show
Documentation introduced by
For interfaces and abstract methods it is generally a good practice to add a @return annotation even if it is just @return void or @return null, so that implementors know what to do in the overridden method.

For interface and abstract methods, it is impossible to infer the return type from the immediate code. In these cases, it is generally advisible to explicitly annotate these methods with a @return doc comment to communicate to implementors of these methods what they are expected to return.

Loading history...
60
}
61