Total Complexity | 8 |
Total Lines | 63 |
Duplicated Lines | 0 % |
Coverage | 90% |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
13 | trait HasValidatorTrait |
||
14 | { |
||
15 | /** |
||
16 | * @return AbstractValidator|null |
||
17 | */ |
||
18 | 5 | public function getValidator() |
|
19 | { |
||
20 | 5 | $validator = $this->generateValidator(); |
|
21 | |||
22 | 5 | return $validator; |
|
23 | } |
||
24 | |||
25 | /** |
||
26 | * @return AbstractValidator |
||
27 | */ |
||
28 | 5 | protected function generateValidator() |
|
34 | } |
||
35 | |||
36 | /** |
||
37 | * @return AbstractValidator |
||
38 | */ |
||
39 | 5 | protected function newValidator() |
|
44 | } |
||
45 | |||
46 | /** |
||
47 | * @return string |
||
48 | */ |
||
49 | 5 | protected function getValidatorClassName() |
|
50 | { |
||
51 | 5 | $mediaType = $this->getMediaType(); |
|
|
|||
52 | 5 | switch ($mediaType) { |
|
53 | 5 | case 'images': |
|
54 | return ImageValidator::class; |
||
55 | 4 | case 'files': |
|
56 | return FileValidator::class; |
||
57 | } |
||
58 | |||
59 | return GenericValidator::class; |
||
60 | } |
||
61 | |||
62 | /** |
||
63 | * @param AbstractValidator $validator |
||
64 | */ |
||
65 | 5 | protected function hydrateValidator($validator) |
|
68 | 5 | } |
|
69 | |||
70 | /** |
||
71 | * @return bool |
||
72 | */ |
||
73 | public function hasCustomValidator() |
||
76 | } |
||
77 | } |
||
78 |