Passed
Push — master ( 691d23...9547f5 )
by Joao
12:18 queued 13s
created

PHPMailerOverride::getMessageEnvelopeParts()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.0625

Importance

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