MathFuncs   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 7
c 0
b 0
f 0
lcom 0
cbo 0
dl 0
loc 72
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 0 4 1
A sub() 0 4 1
A mul() 0 4 1
A div() 0 4 1
A pow() 0 4 1
A comp() 0 4 1
A round() 0 4 1
1
<?php
2
3
namespace FinanCalc\Utils {
4
5
    use FinanCalc\Constants\Defaults;
6
7
    /**
8
     * Class MathFuncs
9
     * @package FinanCalc\Utils
10
     */
11
    class MathFuncs
12
    {
13
        /**
14
         * @param $leftOperand
15
         * @param $rightOperand
16
         * @return string
17
         */
18
        public static function add($leftOperand, $rightOperand)
19
        {
20
            return bcadd($leftOperand, $rightOperand, Defaults::MONEY_DECIMAL_PLACES_PRECISION);
21
        }
22
23
        /**
24
         * @param $leftOperand
25
         * @param $rightOperand
26
         * @return string
27
         */
28
        public static function sub($leftOperand, $rightOperand)
29
        {
30
            return bcsub($leftOperand, $rightOperand, Defaults::MONEY_DECIMAL_PLACES_PRECISION);
31
        }
32
33
        /**
34
         * @param $leftOperand
35
         * @param $rightOperand
36
         * @return string
37
         */
38
        public static function mul($leftOperand, $rightOperand)
39
        {
40
            return bcmul($leftOperand, $rightOperand, Defaults::MONEY_DECIMAL_PLACES_PRECISION);
41
        }
42
43
        /**
44
         * @param $leftOperand
45
         * @param $rightOperand
46
         * @return string
47
         */
48
        public static function div($leftOperand, $rightOperand)
49
        {
50
            return bcdiv($leftOperand, $rightOperand, Defaults::MONEY_DECIMAL_PLACES_PRECISION);
51
        }
52
53
        /**
54
         * @param $leftOperand
55
         * @param $rightOperand
56
         * @return string
57
         */
58
        public static function pow($leftOperand, $rightOperand)
59
        {
60
            return bcpow($leftOperand, $rightOperand, Defaults::MONEY_DECIMAL_PLACES_PRECISION);
61
        }
62
63
        /**
64
         * @param $leftOperand
65
         * @param $rightOperand
66
         * @return int
67
         */
68
        public static function comp($leftOperand, $rightOperand)
69
        {
70
            return bccomp($leftOperand, $rightOperand, Defaults::MONEY_DECIMAL_PLACES_PRECISION);
71
        }
72
73
        /**
74
         * @param $roundedNumber
75
         * @param $precision
76
         * @return string
77
         */
78
        public static function round($roundedNumber, $precision = 2)
79
        {
80
            return (string)number_format((float)$roundedNumber, $precision);
81
        }
82
    }
83
}
84