Passed
Push — master ( 7a33aa...291e70 )
by Peter
02:20
created

Exception   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getErrorInfo() 0 3 1
A __construct() 0 9 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AbterPhp\Framework\Databases\Migrations;
6
7
use Throwable;
8
9
class Exception extends \RuntimeException
10
{
11
    /** @var array */
12
    protected $errorInfo;
13
14
    /**
15
     * Exception constructor.
16
     *
17
     * @param array          $errorInfo
18
     * @param string         $message
19
     * @param int            $code
20
     * @param Throwable|null $previous
21
     */
22
    public function __construct(array $errorInfo, $message = "", $code = 0, Throwable $previous = null)
23
    {
24
        if (array_diff(array_keys($errorInfo), [0, 1, 2])) {
25
            throw new \RuntimeException(sprintf('Invalid errorInfo received for constructing %s.', __CLASS__));
26
        }
27
28
        $this->errorInfo = $errorInfo;
29
30
        parent::__construct($message, $code, $previous);
31
    }
32
33
    /**
34
     * @return array
35
     */
36
    public function getErrorInfo(): array
37
    {
38
        return $this->errorInfo;
39
    }
40
}
41