Passed
Push — master ( 5e9e3d...710625 )
by Maciej
04:36 queued 11s
created

FreshMailException   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 77.78%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 33
ccs 7
cts 9
cp 0.7778
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __toString() 0 3 1
A __construct() 0 6 2
A getDefaultMessage() 0 3 1
1
<?php
2
/**
3
 * File: FreshMailException.php
4
 *
5
 * @author      Maciej Sławik <[email protected]>
6
 * Github:      https://github.com/maciejslawik
7
 */
8
9
namespace MSlwk\FreshMail\Exception;
10
11
use Throwable;
12
13
/**
14
 * Class FreshMailException
15
 *
16
 * @package MSlwk\FreshMail\Exception
17
 */
18
class FreshMailException extends \Exception
19
{
20
    const EXCEPTION_MESSAGE = 'FreshMail exception';
21
22
    /**
23
     * FreshMailException constructor.
24
     *
25
     * @param string $message
26
     * @param int $code
27
     * @param Throwable|null $previous
28
     */
29 686
    public function __construct($message = '', $code = 0, Throwable $previous = null)
30
    {
31 686
        if (!$message) {
32 7
            $message = $this->getDefaultMessage();
33
        }
34 686
        parent::__construct($message, $code, $previous);
35 686
    }
36
37
    /**
38
     * @return string
39
     */
40 7
    protected function getDefaultMessage(): string
41
    {
42 7
        return static::EXCEPTION_MESSAGE;
43
    }
44
45
    /**
46
     * @return string
47
     */
48
    public function __toString()
49
    {
50
        return 'Message: ' . $this->getMessage() . '. Code: ' . $this->getCode();
51
    }
52
}
53