Passed
Push — master ( eff209...0e7332 )
by Edward
05:02
created

InvalidPropertyConfigException   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

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

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
15
    private $propertyName;
16
17
    private $propertyFile;
18
19
    public function __construct(string $propertyName, $propertyFile, Throwable $previous = null)
20
    {
21
        $this->propertyName = $propertyName;
22
        $this->propertyFile = $propertyFile;
23
        parent::__construct($this->buildMessage(), 0, $previous);
24
    }
25
26
    private function buildMessage(): string
27
    {
28
        $fileNameType = gettype($this->propertyFile);
29
30
        return
31
            "Invalid config for Unicode property '{$this->propertyName}': " .
32
            "{$fileNameType} instead of string filename";
33
    }
34
35
    public function getPropertyName(): string
36
    {
37
        return $this->propertyName;
38
    }
39
40
    public function getPropertyFile(): string
41
    {
42
        return $this->propertyFile;
43
    }
44
}
45