1 | <?php |
||||
2 | /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ |
||||
3 | |||||
4 | /** |
||||
5 | * Short File Description |
||||
6 | * |
||||
7 | * PHP version 5 |
||||
8 | * |
||||
9 | * @category aCategory |
||||
10 | * @package aPackage |
||||
11 | * @subpackage aSubPackage |
||||
12 | * @author anAuthor |
||||
13 | * @copyright 2014 a Copyright |
||||
14 | * @license a License |
||||
15 | * @link http://www.aLink.com |
||||
16 | */ |
||||
17 | namespace Appino\Blockchain\Classes\Conversion; |
||||
18 | |||||
19 | /** |
||||
20 | * Short Class Description |
||||
21 | * |
||||
22 | * PHP version 5 |
||||
23 | * |
||||
24 | * @category aCategory |
||||
25 | * @package aPackage |
||||
26 | * @subpackage aSubPackage |
||||
27 | * @author anAuthor |
||||
28 | * @copyright 2014 a Copyright |
||||
29 | * @license a License |
||||
30 | * @link http://www.aLink.com |
||||
31 | */ |
||||
32 | class Conversion |
||||
33 | { |
||||
34 | /** |
||||
35 | * Properties |
||||
36 | */ |
||||
37 | |||||
38 | |||||
39 | /** |
||||
40 | * Methods |
||||
41 | */ |
||||
42 | /** |
||||
43 | * Convert an incoming integer to a BTC string value |
||||
44 | */ |
||||
45 | static function BTC_int2str($val) |
||||
0 ignored issues
–
show
|
|||||
46 | { |
||||
47 | $a = bcmul($val, "1.0", 1); |
||||
48 | return bcdiv($a, "100000000", 8); |
||||
49 | } |
||||
50 | |||||
51 | /** |
||||
52 | * Convert a float value to BTC satoshi integer string |
||||
53 | */ |
||||
54 | static function BTC_float2int($val) |
||||
0 ignored issues
–
show
|
|||||
55 | { |
||||
56 | return bcmul($val, "100000000", 0); |
||||
57 | } |
||||
58 | |||||
59 | /** |
||||
60 | * From comment on http://php.net/manual/en/ref.bc.php |
||||
61 | */ |
||||
62 | static function bcconv($fNumber) |
||||
0 ignored issues
–
show
|
|||||
63 | { |
||||
64 | $sAppend = ''; |
||||
65 | $iDecimals = ini_get('precision') - floor(log10(abs($fNumber))); |
||||
66 | if (0 > $iDecimals) { |
||||
67 | $fNumber *= pow(10, $iDecimals); |
||||
68 | $sAppend = str_repeat('0', -$iDecimals); |
||||
0 ignored issues
–
show
-$iDecimals of type double is incompatible with the type integer expected by parameter $multiplier of str_repeat() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
69 | $iDecimals = 0; |
||||
70 | } |
||||
71 | |||||
72 | return number_format($fNumber, $iDecimals, '.', '').$sAppend; |
||||
0 ignored issues
–
show
It seems like
$iDecimals can also be of type double ; however, parameter $decimals of number_format() does only seem to accept integer , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
73 | } |
||||
74 | } |
||||
75 |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.