Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Mar 31, 2024
1 parent cb81155 commit 8f75583
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/Exporter.php
Expand Up @@ -247,18 +247,16 @@ private function recursiveExport(mixed &$value, int $indentation = 0, ?Recursion
return $this->exportString($value);
}

$whitespace = str_repeat(' ', 4 * $indentation);

if (!$processed) {
$processed = new RecursionContext;
}

if (is_array($value)) {
return $this->exportArray($value, $processed, $whitespace, $indentation);
return $this->exportArray($value, $processed, $indentation);
}

if (is_object($value)) {
return $this->exportObject($value, $processed, $whitespace, $indentation);
return $this->exportObject($value, $processed, $indentation);
}

return var_export($value, true);
Expand Down Expand Up @@ -303,15 +301,16 @@ private function exportString(string $value): string
"'";
}

private function exportArray(array &$value, RecursionContext $processed, string $whitespace, int $indentation): string
private function exportArray(array &$value, RecursionContext $processed, int $indentation): string
{
if (($key = $processed->contains($value)) !== false) {
return 'Array &' . $key;
}

$array = $value;
$key = $processed->add($value);
$values = '';
$array = $value;
$key = $processed->add($value);
$values = '';
$whitespace = str_repeat(' ', 4 * $indentation);

if (count($array) > 0) {
foreach ($array as $k => $v) {
Expand All @@ -330,7 +329,7 @@ private function exportArray(array &$value, RecursionContext $processed, string
return 'Array &' . (string) $key . ' [' . $values . ']';
}

private function exportObject(mixed $value, RecursionContext $processed, string $whitespace, int $indentation): string
private function exportObject(mixed $value, RecursionContext $processed, int $indentation): string
{
$class = $value::class;

Expand All @@ -340,8 +339,9 @@ private function exportObject(mixed $value, RecursionContext $processed, string

$processed->add($value);

$values = '';
$array = $this->toArray($value);
$array = $this->toArray($value);
$values = '';
$whitespace = str_repeat(' ', 4 * $indentation);

if (count($array) > 0) {
foreach ($array as $k => $v) {
Expand Down

0 comments on commit 8f75583

Please sign in to comment.