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

FreshMailException::__toString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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