PHPMailerOverride::getFullMessageEnvelope()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

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