Issues (130)

src/Amount.php (1 issue)

1
<?php
2
3
declare(strict_types=1);
4
5
namespace BitWasp\Bitcoin;
6
7
class Amount
8
{
9
    const COIN = 100000000;
10
11
    /**
12
     * @param int $satoshis
13
     * @return string
14
     */
15 7
    public function toBtc(int $satoshis): string
16
    {
17 7
        return bcdiv((string)$satoshis, (string) self::COIN, 8);
0 ignored issues
show
Bug Best Practice introduced by
The expression return bcdiv((string)$sa... (string)self::COIN, 8) could return the type null which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
18
    }
19
20
    /**
21
     * @param string $btcAmount
22
     * @return int
23
     */
24 7
    public function toSatoshis(string $btcAmount): int
25
    {
26 7
        return (int) bcmul($btcAmount, (string) self::COIN, 0);
27
    }
28
}
29