Validator::addError()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
/**
3
 * Request validator
4
 *
5
 * @file      Validator.php
6
 *
7
 * PHP version 8.0+
8
 *
9
 * @author    Yancharuk Alexander <alex at itvault dot info>
10
 * @copyright © 2012-2021 Alexander Yancharuk <alex at itvault at info>
11
 * @date      2017-01-17 14:28
12
 * @license   The BSD 3-Clause License
13
 *            <https://tldrlegal.com/license/bsd-3-clause-license-(revised)>
14
 */
15
16
namespace Veles\Request\Validator;
17
18
/**
19
 * Class   Validator
20
 *
21
 * @author Yancharuk Alexander <alex at itvault at info>
22
 */
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()
97
	{
98 1
		return $this->getAdapter()->getData();
99
	}
100
}
101