InvalidPropertyConfigException   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 47
ccs 0
cts 13
cp 0
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getPropertyName() 0 3 1
A buildMessage() 0 7 1
A getPropertyFile() 0 3 1
A __construct() 0 5 1
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