Remove unneessary information from iterator

In the iterator in the "NestedValidationException" the only information
that is necessary is the depth of the message, for that reason all the
other information can (and should) be removed.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
This commit is contained in:
Henrique Moody 2018-08-02 08:24:14 +02:00
parent da10941ddc
commit 3ad35ed545
No known key found for this signature in database
GPG key ID: 221E9281655813A6

View file

@ -91,7 +91,6 @@ class NestedValidationException extends ValidationException implements IteratorA
public function getIterator()
{
$childrenExceptions = new SplObjectStorage();
$recursiveIteratorIterator = $this->getRecursiveIterator();
$lastDepth = 0;
@ -118,15 +117,7 @@ class NestedValidationException extends ValidationException implements IteratorA
$lastDepth = $currentDepth;
$lastDepthOriginal = $currentDepthOriginal;
$childrenExceptions->attach(
$childException,
[
'depth' => $currentDepth,
'depth_original' => $currentDepthOriginal,
'previous_depth' => $lastDepth,
'previous_depth_original' => $lastDepthOriginal,
]
);
$childrenExceptions->attach($childException, $currentDepth);
}
return $childrenExceptions;
@ -177,7 +168,7 @@ class NestedValidationException extends ValidationException implements IteratorA
foreach ($exceptions as $exception) {
$messages[] = sprintf(
'%s- %s',
str_repeat(' ', ($exceptions[$exception]['depth'] - $leveler) * 2),
str_repeat(' ', ($exceptions[$exception] - $leveler) * 2),
$exception->getMessage()
);
}