[TASK] Streamline phpdoc annotations in EXT:extbase
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / Validation / Validator / ConjunctionValidator.php
1 <?php
2 namespace TYPO3\CMS\Extbase\Validation\Validator;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Extbase\Error\Result;
18
19 /**
20 * Validator to chain many validators in a conjunction (logical and).
21 */
22 class ConjunctionValidator extends AbstractCompositeValidator
23 {
24 /**
25 * Checks if the given value is valid according to the validators of the conjunction.
26 * Every validator has to be valid, to make the whole conjunction valid.
27 *
28 * @param mixed $value The value that should be validated
29 * @return Result
30 */
31 public function validate($value)
32 {
33 $validators = $this->getValidators();
34 if ($validators->count() > 0) {
35 /** @var Result $result */
36 $result = null;
37 /** @var AbstractValidator $validator */
38 foreach ($validators as $validator) {
39 if ($result === null) {
40 $result = $validator->validate($value);
41 } else {
42 $result->merge($validator->validate($value));
43 }
44 }
45 } else {
46 $result = new Result;
47 }
48
49 return $result;
50 }
51 }