Passed
Branch release/v3.0.0 (c409f3)
by Anatoly
05:44
created

getTranslationDomain()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * It's free open-source software released under the MIT License.
5
 *
6
 * @author Anatoly Nekhay <[email protected]>
7
 * @copyright Copyright (c) 2018, Anatoly Nekhay
8
 * @license https://github.com/sunrise-php/http-router/blob/master/LICENSE
9
 * @link https://github.com/sunrise-php/http-router
10
 */
11
12
declare(strict_types=1);
13
14
namespace Sunrise\Http\Router\Validation\ConstraintViolation;
15
16
use Sunrise\Http\Router\Dictionary\TranslationDomain;
17
use Sunrise\Http\Router\Validation\ConstraintViolationInterface;
18
use Sunrise\Hydrator\Exception\InvalidValueException;
19
20
/**
21
 * @since 3.0.0
22
 */
23
final class HydratorConstraintViolationAdapter implements ConstraintViolationInterface
24
{
25 21
    public function __construct(
26
        private readonly InvalidValueException $hydratorConstraintViolation,
27
    ) {
28 21
    }
29
30 5
    public static function create(InvalidValueException $hydratorConstraintViolation): self
31
    {
32 5
        return new self($hydratorConstraintViolation);
33
    }
34
35 9
    public function getMessage(): string
36
    {
37 9
        return $this->hydratorConstraintViolation->getMessage();
38
    }
39
40 1
    public function getMessageTemplate(): string
41
    {
42 1
        return $this->hydratorConstraintViolation->getMessageTemplate();
43
    }
44
45
    /**
46
     * @inheritDoc
47
     */
48 1
    public function getMessagePlaceholders(): array
49
    {
50 1
        return $this->hydratorConstraintViolation->getMessagePlaceholders();
51
    }
52
53 9
    public function getPropertyPath(): string
54
    {
55 9
        return $this->hydratorConstraintViolation->getPropertyPath();
56
    }
57
58 9
    public function getCode(): string
59
    {
60 9
        return $this->hydratorConstraintViolation->getErrorCode();
61
    }
62
63 9
    public function getInvalidValue(): mixed
64
    {
65 9
        return $this->hydratorConstraintViolation->getInvalidValue();
66
    }
67
68 1
    public function getTranslationDomain(): string
69
    {
70 1
        return TranslationDomain::HYDRATOR;
71
    }
72
}
73