InvalidPropertyConfigException::buildMessage()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 7
ccs 0
cts 4
cp 0
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Remorhaz\UCD\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
    /**
16
     * @var string
17
     */
18
    private $propertyName;
19
20
    /**
21
     * @var mixed
22
     */
23
    private $propertyFile;
24
25
    /**
26
     * InvalidPropertyConfigException constructor.
27
     *
28
     * @param string         $propertyName
29
     * @param mixed          $propertyFile
30
     * @param Throwable|null $previous
31
     */
32
    public function __construct(string $propertyName, $propertyFile, Throwable $previous = null)
33
    {
34
        $this->propertyName = $propertyName;
35
        $this->propertyFile = $propertyFile;
36
        parent::__construct($this->buildMessage(), 0, $previous);
37
    }
38
39
    private function buildMessage(): string
40
    {
41
        $fileNameType = gettype($this->propertyFile);
42
43
        return
44
            "Invalid config for Unicode property '{$this->propertyName}': " .
45
            "{$fileNameType} instead of string filename";
46
    }
47
48
    public function getPropertyName(): string
49
    {
50
        return $this->propertyName;
51
    }
52
53
    /**
54
     * @return mixed
55
     */
56
    public function getPropertyFile()
57
    {
58
        return $this->propertyFile;
59
    }
60
}
61