Skip to content

Commit

Permalink
not working attempt Stylish
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimir-xz committed Feb 19, 2024
1 parent e7b8c34 commit 0db008f
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/Formatters/Stylish.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function makeStylish(mixed $comparedData, int $depth = 0, string $separator = '
}
$emptySpace = str_repeat($separator, $depth);
$iter = function ($comparedData, $depth) use (&$iter, $separator, $offset) {
$result = array_map(function ($key, $data) use ($separator, $depth, $offset) {
$result = array_map(function ($key, $data) use ($separator, $depth, $offset, &$iter) {
$nextDepth = $depth + 1;
$emptySpace = substr(str_repeat($separator, $nextDepth), $offset, null);
['status' => $status, 'symbol' => $symbol, 'difference' => $difference] = getNode($data);
Expand All @@ -69,12 +69,9 @@ function makeStylish(mixed $comparedData, int $depth = 0, string $separator = '
$value = current($difference);
}
if ($status === 'old and new') {
$oldAndNewValues = array_map(function ($node) use ($nextDepth, $emptySpace) {
['symbol' => $symbol, 'difference' => $difference] = getNode($node);
$key = key($difference);
$value = current($difference);
$stringValue = makeStylish($value, $nextDepth);
return "{$emptySpace}{$symbol}{$key}: {$stringValue}";
$oldAndNewValues = array_map(function ($node) use ($nextDepth, &$iter, $difference) {
$result = $iter($difference, $nextDepth);
return implode("\n", $result);
}, $value);
return implode("\n", $oldAndNewValues);
} else {
Expand Down

0 comments on commit 0db008f

Please sign in to comment.