InvalidPropertyConfigException   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
dl 0
loc 30
rs 10
c 1
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getPropertyName() 0 3 1
A __construct() 0 5 1
A getPropertyFile() 0 3 1
A buildMessage() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Remorhaz\UniLex\RegExp\Exception;
6
7
use DomainException;
8
use Throwable;
9
10
use function gettype;
11
12
final class InvalidPropertyConfigException extends DomainException implements ExceptionInterface
13
{
14
    private $propertyName;
15
16
    private $propertyFile;
17
18
    public function __construct(string $propertyName, $propertyFile, Throwable $previous = null)
19
    {
20
        $this->propertyName = $propertyName;
21
        $this->propertyFile = $propertyFile;
22
        parent::__construct($this->buildMessage(), 0, $previous);
23
    }
24
25
    private function buildMessage(): string
26
    {
27
        $fileNameType = gettype($this->propertyFile);
28
29
        return
30
            "Invalid config for Unicode property '{$this->propertyName}': " .
31
            "{$fileNameType} instead of string filename";
32
    }
33
34
    public function getPropertyName(): string
35
    {
36
        return $this->propertyName;
37
    }
38
39
    public function getPropertyFile(): string
40
    {
41
        return $this->propertyFile;
42
    }
43
}
44