BCMathHelper   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 22
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A bcround() 0 9 2
1
<?php
2
3
namespace Ksdev\NBPCurrencyConverter;
4
5
class BCMathHelper
6
{
7
    /**
8
     * Round the arbitrary precision number
9
     *
10
     * @see http://php.net/manual/en/function.bcscale.php#79628
11
     *
12
     * @param string $number
13
     * @param int $scale
14
     *
15
     * @return string
16
     */
17
    public static function bcround($number, $scale = 0)
18
    {
19
        $fix = '5';
20
        for ($i = 0; $i < $scale; $i++) {
21
            $fix = "0{$fix}";
22
        }
23
        $number = bcadd($number, "0.{$fix}", $scale + 1);
24
        return bcdiv($number, '1.0', $scale);
25
    }
26
}
27