Passed
Push — master ( e7c89c...d9a062 )
by Sebastian
06:11 queued 12s
created

Mailcode_Exception   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 10
c 2
b 0
f 0
dl 0
loc 34
rs 10
wmc 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A hasCollection() 0 3 1
A __construct() 0 9 3
A getCollection() 0 3 1
A setCollection() 0 3 1
1
<?php
2
/**
3
 * File containing the {@see \Mailcode\Mailcode_Exception} class.
4
 *
5
 * @package Mailcode
6
 * @subpackage Core
7
 * @see \Mailcode\Mailcode_Exception
8
 */
9
10
namespace Mailcode;
11
12
use AppUtils\BaseException;
13
14
/**
15
 * Mailcode exception.
16
 *
17
 * @package Mailcode
18
 * @subpackage Core
19
 * @author Sebastian Mordziol <[email protected]>
20
 */
21
class Mailcode_Exception extends BaseException
22
{
23
    public function __construct(string $message, ?string $details = null, $code = null, $previous = null)
24
    {
25
        if(defined('TESTS_ROOT') && !empty($details)) {
26
            $message .= PHP_EOL.
27
                'Details:'.PHP_EOL.
28
                $details;
29
        }
30
31
        parent::__construct($message, $details, $code, $previous);
32
    }
33
34
    /**
35
     * @var Mailcode_Collection|null
36
     */
37
    private ?Mailcode_Collection $collection = null;
38
39
    public function setCollection(Mailcode_Collection $collection) : void
40
    {
41
        $this->collection = $collection;
42
    }
43
44
    /**
45
     * @return Mailcode_Collection|null
46
     */
47
    public function getCollection(): ?Mailcode_Collection
48
    {
49
        return $this->collection;
50
    }
51
52
    public function hasCollection() : bool
53
    {
54
        return isset($this->collection);
55
    }
56
}
57