MailRecorder   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 2
eloc 4
c 3
b 0
f 0
dl 0
loc 27
ccs 5
cts 5
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A beforeSendPerformed() 0 3 1
1
<?php
2
3
namespace Spinen\MailAssertions;
4
5
use Swift_Events_EventListener;
6
use Swift_Events_SendEvent;
7
8
/**
9
 * Class MailRecorder
10
 *
11
 * @package Spinen\MailAssertions
12
 */
13
class MailRecorder implements Swift_Events_EventListener
14
{
15
    /**
16
     * @var mixed
17
     */
18
    protected $test;
19
20
    /**
21
     * MailRecorder constructor.
22
     *
23
     * @param mixed $test The PhpUnit TestCase class to use
24
     */
25 2
    public function __construct($test)
26
    {
27 2
        $this->test = $test;
28 2
    }
29
30
    /**
31
     * Called by Laravel before email is given to the transporter.
32
     *
33
     * Passes the email to the test, so that assertions can be ran against the messages.
34
     *
35
     * @param Swift_Events_SendEvent $event
36
     */
37 1
    public function beforeSendPerformed(Swift_Events_SendEvent $event)
38
    {
39 1
        $this->test->recordMail($event->getMessage());
40 1
    }
41
}
42