FaultManagerException   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 17
c 1
b 0
f 0
dl 0
loc 53
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A send() 0 8 1
A __construct() 0 16 2
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * Author: panosru
7
 * Date: 23/04/2018
8
 * Time: 14:51
9
 */
10
11
namespace Omega\FaultManager\Abstracts;
12
13
use Omega\FaultManager\Interfaces\FaultManagerException as IFaultManagerException;
14
use Omega\FaultManager\Traits\FaultMutator as TFaultMutator;
15
16
/**
17
 * Class FaultManagerException
18
 * @package Omega\FaultManager\Abstracts
19
 */
20
abstract class FaultManagerException extends \Hoa\Exception\Exception implements IFaultManagerException
21
{
22
    use TFaultMutator;
23
24
    /** @var int */
25
    protected $code = 66000;
26
27
    /** @var string */
28
    protected $message = '';
29
30
    /** @var array */
31
    protected $arguments = [];
32
33
    /**
34
     * FaultManagerException constructor.
35
     * @param null|string $message
36
     * @param int|null $code
37
     * @param null|\Throwable $previous
38
     * @param array|null $arguments
39
     */
40
    public function __construct(
41
        ?string $message = null,
42
        ?int $code = null,
43
        ?\Throwable $previous = null,
44
        ?array $arguments = null
45
    ) {
46
        // In case an empty message is passed, then use the one from $this->message
47
        if (empty($message)) {
48
            $message = null; // @codeCoverageIgnore
49
        }
50
51
        parent::__construct(
52
            $message ?? $this->message,
53
            $code ?? $this->code,
54
            $arguments ?? $this->arguments,
55
            $previous
56
        );
57
    }
58
59
    /**
60
     * Override parent::send()
61
     *
62
     * Sends the exception on `hoa://Event/Exception`.
63
     * @codeCoverageIgnore
64
     */
65
    public function send(): void
66
    {
67
        self::mutate($this);
68
69
        \Hoa\Event\Event::notify(
70
            'hoa://Event/Exception',
71
            $this,
72
            new \Hoa\Event\Bucket($this)
73
        );
74
    }
75
}
76