InvalidPropertyConfigException::buildMessage()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 7
rs 10
cc 1
nc 1
nop 0
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