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