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

Exception::getErrorInfo()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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