Skip to content

Commit

Permalink
Simplify hash algorithm lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
kylekatarnls committed Feb 3, 2018
1 parent ea2983a commit 5dbd484
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions src/Phug/Renderer/Adapter/FileAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,21 +183,15 @@ private function hashPrint($input)
$algorithm = $algorithms[0];
$number = 0;
foreach ($algorithms as $hashAlgorithm) {
if (strpos($hashAlgorithm, 'md') === 0) {
$hashNumber = substr($hashAlgorithm, 2);
if ($hashNumber > $number) {
$number = $hashNumber;
$algorithm = $hashAlgorithm;
foreach (['md', 'sha'] as $type) {
if (strpos($hashAlgorithm, $type) === 0) {
$hashNumber = substr($hashAlgorithm, strlen($type));
if ($hashNumber > $number) {
$number = $hashNumber;
$algorithm = $hashAlgorithm;
}
continue 2;
}
continue;
}
if (strpos($hashAlgorithm, 'sha') === 0) {
$hashNumber = substr($hashAlgorithm, 3);
if ($hashNumber > $number) {
$number = $hashNumber;
$algorithm = $hashAlgorithm;
}
continue;
}
}

Expand Down

0 comments on commit 5dbd484

Please sign in to comment.