Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm committed Jun 17, 2024
1 parent 96c4edd commit b5a2998
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Exporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function shortenedRecursiveExport(array &$data, ?RecursionContext $proces
$overallCount = count($data, COUNT_RECURSIVE);
$counter = 0;

$export = $this->shortenedCountedRecursiveExport($data, $processed, $overallCount, $counter);
$export = $this->shortenedCountedRecursiveExport($data, $processed, $counter);

if ($overallCount > $this->shortenArraysLongerThan) {
$export .= sprintf(' ...%d more elements', $overallCount - $this->shortenArraysLongerThan);
Expand Down Expand Up @@ -189,7 +189,7 @@ public function toArray(mixed $value): array
return $array;
}

private function shortenedCountedRecursiveExport(array &$data, RecursionContext $processed, int $overallCount, int &$counter): string
private function shortenedCountedRecursiveExport(array &$data, RecursionContext $processed, int &$counter): string
{
$result = [];

Expand All @@ -199,15 +199,15 @@ private function shortenedCountedRecursiveExport(array &$data, RecursionContext
$processed->add($data);

foreach ($array as $key => $value) {
if ($overallCount > $this->shortenArraysLongerThan && $counter > $this->shortenArraysLongerThan) {
if ($counter > $this->shortenArraysLongerThan) {
break;
}

if (is_array($value)) {
if ($processed->contains($data[$key]) !== false) {
$result[] = '*RECURSION*';
} else {
$result[] = '[' . $this->shortenedCountedRecursiveExport($data[$key], $processed, $overallCount, $counter) . ']';
$result[] = '[' . $this->shortenedCountedRecursiveExport($data[$key], $processed, $counter) . ']';
}
} else {
$result[] = $this->shortenedExport($value);
Expand Down

0 comments on commit b5a2998

Please sign in to comment.