ModifyPlugin::getModifier()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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