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

PHPMailerOverride   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 90.91%

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 1
cbo 2
dl 0
loc 34
ccs 10
cts 11
cp 0.9091
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getFullMessageEnvelope() 0 6 1
A getMessageEnvelopeParts() 0 8 2
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