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
|
|
|
|