Skip to content

Commit

Permalink
Optimise Framework\Phrase\Renderer\Placeholder
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Di Fabio committed Jun 17, 2015
1 parent 8e1e4b9 commit 32a856f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/internal/Magento/Framework/Phrase/Renderer/Placeholder.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ public function render(array $source, array $arguments)
$text = end($source);

if ($arguments) {
$placeholders = array_map(
function ($key) {
return '%' . (is_int($key) ? strval($key + 1) : $key);
},
array_keys($arguments)
);
$placeholders = array_map([$this, 'keyToPlaceholder'], array_keys($arguments));
$pairs = array_combine($placeholders, $arguments);
$text = strtr($text, $pairs);
}

return $text;
}

private function keyToPlaceholder($key)
{
return '%' . (is_int($key) ? strval($key + 1) : $key);
}
}

0 comments on commit 32a856f

Please sign in to comment.