HydratorConstraintViolationAdapter::getMessage()   A
last analyzed

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
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
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\Validation\ConstraintViolationInterface;
17
use Sunrise\Hydrator\Exception\InvalidValueException;
18
19
/**
20
 * @since 3.0.0
21
 */
22
final class HydratorConstraintViolationAdapter implements ConstraintViolationInterface
23
{
24 21
    public function __construct(
25
        private readonly InvalidValueException $hydratorConstraintViolation,
26
    ) {
27 21
    }
28
29 5
    public static function create(InvalidValueException $hydratorConstraintViolation): self
30
    {
31 5
        return new self($hydratorConstraintViolation);
32
    }
33
34 9
    public function getMessage(): string
35
    {
36 9
        return $this->hydratorConstraintViolation->getMessage();
37
    }
38
39 1
    public function getMessageTemplate(): string
40
    {
41 1
        return $this->hydratorConstraintViolation->getMessageTemplate();
42
    }
43
44
    /**
45
     * @inheritDoc
46
     */
47 1
    public function getMessagePlaceholders(): array
48
    {
49 1
        return $this->hydratorConstraintViolation->getMessagePlaceholders();
50
    }
51
52 9
    public function getPropertyPath(): string
53
    {
54 9
        return $this->hydratorConstraintViolation->getPropertyPath();
55
    }
56
57 9
    public function getCode(): string
58
    {
59 9
        return $this->hydratorConstraintViolation->getErrorCode();
60
    }
61
62 9
    public function getInvalidValue(): mixed
63
    {
64 9
        return $this->hydratorConstraintViolation->getInvalidValue();
65
    }
66
67 1
    public function getTranslationDomain(): string
68
    {
69 1
        return $this->hydratorConstraintViolation->getTranslationDomain();
70
    }
71
}
72