PropertyFileNotLoadedException   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
dl 0
loc 39
rs 10
c 1
b 0
f 0
wmc 5

4 Methods

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