-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathValidatorPool.php
63 lines (57 loc) · 1.46 KB
/
ValidatorPool.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
/**
* ValidatorPool.php
*
* PHP Version 5
*
* @category magento2
* @package magento2
* @author David Verholen <[email protected]>
* @license http://opensource.org/licenses/OSL-3.0 OSL-3.0
* @link http://github.com/davidverholen
*/
namespace DavidVerholen\DynamicComponentRegistry\Validator\Component;
use DavidVerholen\DynamicComponentRegistry\Api\Data\ComponentInterface;
/**
* Class ValidatorPool
*
* @category magento2
* @package DavidVerholen\DynamicComponentRegistry\Validator\Component
* @author David Verholen <[email protected]>
* @license http://opensource.org/licenses/OSL-3.0 OSL-3.0
* @link http://github.com/davidverholen
*/
class ValidatorPool
{
/**
* @var ValidatorInterface[]
*/
protected $validators;
/**
* ValidatorPool constructor.
*
* @param ValidatorInterface[] $validators
*/
public function __construct(array $validators = [])
{
$this->validators = $validators;
}
/**
* validateAll
*
* @param ComponentInterface $component
*
* @return array
*/
public function validateAll(ComponentInterface $component)
{
$errors = [];
/** @var ValidatorInterface $validator */
foreach ($this->validators as $validator) {
if (false === $validator->validate($component)) {
$errors = array_merge($errors, $validator->getErrors());
}
}
return $errors;
}
}