ErrorException::getErrorCode()   A
last analyzed

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
declare(strict_types=1);
4
5
namespace InShore\Bookwhen\Exceptions;
6
7
use Exception;
8
9
final class ErrorException extends Exception
10
{
11
    /**
12
     * Creates a new Exception instance.
13
     *
14
     * @param  array{message: string, type: ?string, code: ?string}  $contents
15
     */
16
    public function __construct(private readonly array $contents)
17
    {
18
        parent::__construct($contents['message']);
19
    }
20
21
    /**
22
     * Returns the error message.
23
     */
24
    public function getErrorMessage(): string
25
    {
26
        return $this->getMessage();
27
    }
28
29
    /**
30
     * Returns the error type.
31
     */
32
    public function getErrorType(): ?string
33
    {
34
        return $this->contents['type'];
35
    }
36
37
    /**
38
     * Returns the error type.
39
     */
40
    public function getErrorCode(): ?string
41
    {
42
        return $this->contents['code'];
43
    }
44
}
45