Amount::toBtc()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
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