| Total Complexity | 7 |
| Total Lines | 76 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 23 | class Validator implements ValidatorInterface, ValidatorAdapterInterface |
||
| 24 | { |
||
| 25 | /** @var ValidatorInterface */ |
||
| 26 | protected $adapter; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Add error |
||
| 30 | * |
||
| 31 | * @param array $error |
||
| 32 | */ |
||
| 33 | 1 | public function addError(array $error) |
|
| 34 | { |
||
| 35 | 1 | $this->getAdapter()->addError($error); |
|
| 36 | } |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Get error array |
||
| 40 | * |
||
| 41 | * @return array |
||
| 42 | */ |
||
| 43 | 1 | public function getErrors() |
|
| 44 | { |
||
| 45 | 1 | return $this->getAdapter()->getErrors(); |
|
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * Validate data |
||
| 50 | * |
||
| 51 | * @param mixed $data |
||
| 52 | * @param mixed $definitions |
||
| 53 | */ |
||
| 54 | 2 | public function check($data, $definitions) |
|
| 55 | { |
||
| 56 | 2 | $this->getAdapter()->check($data, $definitions); |
|
| 57 | } |
||
| 58 | |||
| 59 | /** |
||
| 60 | * Check validation result |
||
| 61 | * |
||
| 62 | * @return bool |
||
| 63 | */ |
||
| 64 | 1 | public function isValid() |
|
| 65 | { |
||
| 66 | 1 | return $this->getAdapter()->isValid(); |
|
| 67 | } |
||
| 68 | |||
| 69 | /** |
||
| 70 | * Getting adapter |
||
| 71 | * |
||
| 72 | * @return ValidatorInterface |
||
| 73 | */ |
||
| 74 | 7 | public function getAdapter() |
|
| 75 | { |
||
| 76 | 7 | return $this->adapter; |
|
| 77 | } |
||
| 78 | |||
| 79 | /** |
||
| 80 | * Set validator |
||
| 81 | * |
||
| 82 | * @param ValidatorInterface $adapter |
||
| 83 | * |
||
| 84 | * @return $this |
||
| 85 | */ |
||
| 86 | 7 | public function setAdapter(ValidatorInterface $adapter) |
|
| 87 | { |
||
| 88 | 7 | $this->adapter = $adapter; |
|
| 89 | |||
| 90 | 7 | return $this; |
|
| 91 | } |
||
| 92 | |||
| 93 | /** |
||
| 94 | * Get valid data |
||
| 95 | */ |
||
| 96 | 1 | public function getData() |
|
| 99 | } |
||
| 100 | } |
||
| 101 |