Passed
Push — master ( 7ea105...f7c21b )
by Joao
39s
created

PHPMailerOverride::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
3
namespace ByJG\Mail\Override;
4
5
use ByJG\Mail\Exception\InvalidMessageFormatException;
6
7
class PHPMailerOverride extends \PHPMailer
8
{
9 8
    public function __construct($exceptions = null)
10
    {
11 8
        parent::__construct($exceptions);
12 8
        $this->XMailer = 'PHPMailer (https://github.com/PHPMailer/PHPMailer)';
13 8
    }
14
15
    /**
16
     * @return string
17
     * @throws \ByJG\Mail\Exception\InvalidMessageFormatException
18
     * @throws \phpmailerException
19
     */
20 8
    public function getFullMessageEnvelope()
21
    {
22 8
        $parts = $this->getMessageEnvelopeParts();
23
24 8
        return $parts['header'] . $parts['body'];
25
    }
26
27
    /**
28
     * @return array
29
     * @throws \ByJG\Mail\Exception\InvalidMessageFormatException
30
     * @throws \phpmailerException
31
     */
32 8
    public function getMessageEnvelopeParts()
33
    {
34 8
        if (!$this->preSend()) {
35
            throw new InvalidMessageFormatException('Invalid Message Format');
36
        }
37
38 8
        return ["header" => $this->MIMEHeader, "body" => $this->MIMEBody];
39
    }
40
}
41