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

HydratorConstraintViolationAdapter   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 48
ccs 18
cts 18
cp 1
rs 10
c 0
b 0
f 0
wmc 9

9 Methods

Rating   Name   Duplication   Size   Complexity  
A getMessage() 0 3 1
A getInvalidValue() 0 3 1
A getMessageTemplate() 0 3 1
A __construct() 0 3 1
A create() 0 3 1
A getCode() 0 3 1
A getPropertyPath() 0 3 1
A getTranslationDomain() 0 3 1
A getMessagePlaceholders() 0 3 1
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