IntegerFormatter with length param.
This commit is contained in:
parent
264ad69e9d
commit
51ece8f887
@ -25,10 +25,20 @@ class Integer implements IFormatter
|
||||
*/
|
||||
public static function format($value)
|
||||
{
|
||||
$value = (string) $value;
|
||||
$arguments = func_get_args();
|
||||
$digit = 64;
|
||||
|
||||
if (isset($arguments[1]) && is_numeric($arguments[1])) {
|
||||
$digit = intval($arguments[1]);
|
||||
}
|
||||
$bn = Utils::toBn($value);
|
||||
$bnHex = $bn->toHex(true);
|
||||
$padded = mb_substr($bnHex, 0, 1);
|
||||
|
||||
return implode('', array_fill(0, 64-mb_strlen($bnHex), $padded)) . $bnHex;
|
||||
|
||||
if ($padded !== 'f') {
|
||||
$padded = '0';
|
||||
}
|
||||
return implode('', array_fill(0, $digit-mb_strlen($bnHex), $padded)) . $bnHex;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user