MailRecorder::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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