Conditions | 2 |
Paths | 2 |
Total Lines | 15 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 4 |
CRAP Score | 2 |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php namespace Arcanedev\Units\Traits; |
||
20 | protected static function calculate($a, $operator, $b) |
||
21 | { |
||
22 | $operations = $operations = [ |
||
23 | '+' => function ($a, $b) { return $a + $b; }, |
||
24 | '-' => function ($a, $b) { return $a - $b; }, |
||
25 | 'x' => function ($a, $b) { return $a * $b; }, |
||
26 | '*' => function ($a, $b) { return $a * $b; }, |
||
27 | '/' => function ($a, $b) { return $a / $b; }, |
||
28 | '^' => function ($a, $b) { return pow($a, $b); }, |
||
29 | 102 | ]; |
|
30 | |||
31 | 136 | return array_key_exists($operator, $operations) |
|
32 | 134 | ? call_user_func_array($operations[$operator], [$a, $b]) |
|
33 | 128 | : $a; |
|
34 | } |
||
35 | } |
||
36 |