| Total Complexity | 8 |
| Total Lines | 63 |
| Duplicated Lines | 0 % |
| Coverage | 86.96% |
| 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() |
|
| 29 | { |
||
| 30 | 5 | $validator = $this->newValidator(); |
|
| 31 | 5 | $this->hydrateValidator($validator); |
|
| 32 | |||
| 33 | 5 | return $validator; |
|
| 34 | } |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @return AbstractValidator |
||
| 38 | */ |
||
| 39 | 5 | protected function newValidator() |
|
| 40 | { |
||
| 41 | 5 | $class = $this->getValidatorClassName(); |
|
| 42 | |||
| 43 | 5 | return new $class(); |
|
| 44 | } |
||
| 45 | |||
| 46 | /** |
||
| 47 | * @return string |
||
| 48 | */ |
||
| 49 | 5 | protected function getValidatorClassName() |
|
| 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 |