mirror of
https://github.com/Respect/Validation.git
synced 2026-03-16 15:25:45 +01:00
Most changes was made by php-cs-fixer. Also removes unused `RecursiveTreeIterator` class.
44 lines
997 B
PHP
44 lines
997 B
PHP
<?php
|
|
namespace Respect\Validation\Rules;
|
|
|
|
class AllOf extends AbstractComposite
|
|
{
|
|
public function assert($input)
|
|
{
|
|
$exceptions = $this->validateRules($input);
|
|
$numRules = count($this->rules);
|
|
$numExceptions = count($exceptions);
|
|
$summary = array(
|
|
'total' => $numRules,
|
|
'failed' => $numExceptions,
|
|
'passed' => $numRules - $numExceptions,
|
|
);
|
|
if (!empty($exceptions)) {
|
|
throw $this->reportError($input, $summary)->setRelated($exceptions);
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
public function check($input)
|
|
{
|
|
foreach ($this->getRules() as $v) {
|
|
if (!$v->check($input)) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
public function validate($input)
|
|
{
|
|
foreach ($this->getRules() as $v) {
|
|
if (!$v->validate($input)) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|