Skip to content

Commit

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

0 comments on commit 720f204

Please sign in to comment.