ResultNumberFormatter   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 7
c 1
b 0
f 0
dl 0
loc 21
ccs 6
cts 6
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A formatCrypto() 0 3 1
A formatFiat() 0 3 1
A format() 0 3 1
1
<?php
2
3
namespace Sarnado\Converter\Helpers;
4
5
class ResultNumberFormatter
6
{
7
    const DEFAULT_SCALE = 12;
8
9
    const FIAT_BC_SCALE = 5;
10
11
    const CRYPTO_BC_SCALE = 8;
12
13 36
    public static function formatFiat($value, int $scale = self::FIAT_BC_SCALE): string
14
    {
15 36
        return self::format($value, $scale);
16
    }
17
18 18
    public static function formatCrypto($value, int $scale = self::CRYPTO_BC_SCALE): string
19
    {
20 18
        return self::format($value, $scale);
21
    }
22
23 54
    public static function format($value, int $scale = self::DEFAULT_SCALE): string
24
    {
25 54
        return (string) number_format($value, $scale, '.', '');
26
    }
27
}
28