ModifyPlugin   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 45
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getModifier() 0 4 1
A beforeSendPerformed() 0 6 1
A sendPerformed() 0 4 1
1
<?php
2
3
namespace CL\Swiftmailer;
4
5
use Swift_Events_SendListener;
6
use Swift_Events_SendEvent;
7
8
/**
9
 * @author    Ivan Kerin <[email protected]>
10
 * @copyright 2015, Clippings Ltd.
11
 * @license   http://spdx.org/licenses/BSD-3-Clause
12
 */
13
class ModifyPlugin implements Swift_Events_SendListener
14
{
15
    /**
16
     * @var callable
17
     */
18
    private $modifier;
19
20
    /**
21
     * @param callable $modifier
22
     */
23 2
    function __construct(callable $modifier)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
24
    {
25 2
        $this->modifier = $modifier;
26 2
    }
27
28
    /**
29
     * @return callable
30
     */
31 1
    public function getModifier()
32
    {
33 1
        return $this->modifier;
34
    }
35
36
    /**
37
     * Apply the modifier to the Swift_Message
38
     *
39
     * @param Swift_Events_SendEvent $evt
40
     */
41 1
    public function beforeSendPerformed(Swift_Events_SendEvent $evt)
42
    {
43 1
        $message = $evt->getMessage();
44
45 1
        call_user_func($this->modifier, $message);
46 1
    }
47
48
    /**
49
     * Do nothing
50
     *
51
     * @param Swift_Events_SendEvent $evt
52
     */
53 1
    public function sendPerformed(Swift_Events_SendEvent $evt)
54
    {
55
        // Do Nothing
56 1
    }
57
}
58