Completed
Push — master ( 2a7a8a...bafaf6 )
by ARCANEDEV
06:19
created

Calculatable   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
c 1
b 0
f 0
lcom 0
cbo 0
dl 0
loc 34
ccs 13
cts 13
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
C calculate() 0 22 7
1
<?php namespace Arcanedev\Units\Traits;
2
3
/**
4
 * Trait     Calculatable
5
 *
6
 * @package  Arcanedev\Units\Traits
7
 * @author   ARCANEDEV <[email protected]>
8
 */
9
trait Calculatable
10
{
11
    /**
12
     * Calculate the value.
13
     *
14
     * @param  float|int  $a
15
     * @param  string     $operator
16
     * @param  float|int  $b
17
     *
18
     * @return float|int
19
     */
20 136
    protected static function calculate($a, $operator, $b)
21
    {
22
        switch ($operator) {
23 136
            case '+':
24 40
                return $a + $b;
25
26 104
            case '-':
27 24
                return $a - $b;
28
29 80
            case 'x':
30 74
            case '*':
31 24
                return $a * $b;
32
33 56
            case '/':
34 24
                return $a / $b;
35
36 32
            case '^':
37 24
                return pow($a, $b);
38
        }
39
40 8
        return $a;
41
    }
42
}
43