Skip to content

Commit

Permalink
Merge pull request #617 from ergebnis/fix/reduce
Browse files Browse the repository at this point in the history
Fix: Use `array_reduce()`
  • Loading branch information
localheinz committed Dec 29, 2021
2 parents a8203cb + 3a464db commit 30d7a2f
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/ChainNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ public function __construct(NormalizerInterface ...$normalizers)

public function normalize(Json $json): Json
{
foreach ($this->normalizers as $normalizer) {
$json = $normalizer->normalize($json);
}

return $json;
return \array_reduce(
$this->normalizers,
static function (Json $json, NormalizerInterface $normalizer): Json {
return $normalizer->normalize($json);
},
$json,
);
}
}

0 comments on commit 30d7a2f

Please sign in to comment.