Completed
Push — master ( 9d6ccc...1aa3bc )
by Andrii
02:09
created

PhpCalculator::add()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
crap 1
1
<?php
2
/**
3
 * PHP Units of Measure Library.
4
 *
5
 * @link      https://github.com/hiqdev/php-units
6
 * @package   php-units
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiqdev\php\units\calculators;
12
13
use hiqdev\php\units\CalculatorInterface;
14
15
/**
16
 * @author Andrii Vasyliev <[email protected]>
17
 */
18
class PhpCalculator implements CalculatorInterface
19
{
20
    /**
21
     * {@inheritdoc}
22
     */
23
    public static function isSupported()
24
    {
25
        return true;
26
    }
27
28
    /**
29
     * {@inheritdoc}
30
     */
31 2
    public function compare($a, $b)
32
    {
33 2
        return ($a < $b) ? -1 : (($a > $b) ? 1 : 0);
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39 1
    public function add($amount, $addend)
40
    {
41 1
        $result = $amount + $addend;
42
43 1
        return $result;
44
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49 1
    public function subtract($amount, $subtrahend)
50
    {
51 1
        $result = $amount - $subtrahend;
52
53 1
        return $result;
54
    }
55
56
    /**
57
     * {@inheritdoc}
58
     */
59 6
    public function multiply($amount, $multiplier)
60
    {
61 6
        $result = $amount * $multiplier;
62
63 6
        return $result;
64
    }
65
66
    /**
67
     * {@inheritdoc}
68
     */
69 5
    public function divide($amount, $divisor)
70
    {
71 5
        $result = $amount / $divisor;
72
73 5
        return $result;
74
    }
75
76
    /**
77
     * {@inheritdoc}
78
     */
79
    public function ceil($number)
80
    {
81
        return ceil($number);
82
    }
83
84
    /**
85
     * {@inheritdoc}
86
     */
87
    public function floor($number)
88
    {
89
        return floor($number);
90
    }
91
92
    /**
93
     * {@inheritdoc}
94
     */
95
    public function absolute($number)
96
    {
97
        throw new \Exception();
98
    }
99
100
    /**
101
     * {@inheritdoc}
102
     */
103
    public function round($number, $roundingMode)
104
    {
105
        throw new \Exception();
106
    }
107
}
108