ErrorException   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 34
ccs 0
cts 8
cp 0
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getErrorCode() 0 3 1
A getErrorMessage() 0 3 1
A __construct() 0 3 1
A getErrorType() 0 3 1
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