PropertyFileNotLoadedException   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
c 1
b 0
f 0
dl 0
loc 54
ccs 0
cts 18
cp 0
rs 10
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getErrorMessage() 0 3 1
A __construct() 0 10 1
A getPropertyName() 0 3 1
A getPropertyFile() 0 3 1
A buildMessage() 0 9 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Remorhaz\UCD\Exception;
6
7
use RuntimeException;
8
use Throwable;
9
10
final class PropertyFileNotLoadedException extends RuntimeException implements ExceptionInterface
11
{
12
13
    /**
14
     * @var string
15
     */
16
    private $propertyName;
17
18
    /**
19
     * @var string
20
     */
21
    private $propertyFile;
22
23
    /**
24
     * @var string|null
25
     */
26
    private $errorMessage;
27
28
    public function __construct(
29
        string $propertyName,
30
        string $propertyFile,
31
        ?string $errorMessage,
32
        Throwable $previous = null
33
    ) {
34
        $this->propertyName = $propertyName;
35
        $this->propertyFile = $propertyFile;
36
        $this->errorMessage = $errorMessage;
37
        parent::__construct($this->buildMessage(), 0, $previous);
38
    }
39
40
    private function buildMessage(): string
41
    {
42
        $message =
43
            "Failed to load range set for Unicode property '{$this->propertyName}' " .
44
            "from file {$this->propertyFile}";
45
46
        return isset($this->errorMessage)
47
            ? "{$message}:\n{$this->errorMessage}"
48
            : $message;
49
    }
50
51
    public function getPropertyName(): string
52
    {
53
        return $this->propertyName;
54
    }
55
56
    public function getPropertyFile(): string
57
    {
58
        return $this->propertyFile;
59
    }
60
61
    public function getErrorMessage(): ?string
62
    {
63
        return $this->errorMessage;
64
    }
65
}
66