MathInterface
last analyzed

Size/Duplication

Total Lines 191
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 191
c 0
b 0
f 0

18 Methods

Rating   Name   Duplication   Size   Complexity  
add() 0 1 ?
subtract() 0 1 ?
multiply() 0 1 ?
divide() 0 1 ?
compare() 0 1 ?
modulus() 0 1 ?
power() 0 1 ?
squareRoot() 0 1 ?
absolute() 0 1 ?
negate() 0 1 ?
factorial() 0 1 ?
gcd() 0 1 ?
root() 0 1 ?
nextPrime() 0 1 ?
isPrime() 0 1 ?
isPerfectSquare() 0 1 ?
gamma() 0 1 ?
logGamma() 0 1 ?
1
<?php
2
3
namespace Tdn\PhpTypes\Math;
4
5
/**
6
 * Interface MathInterface.
7
 */
8
interface MathInterface
9
{
10
    /**
11
     * Float operation.
12
     */
13
    const TYPE_FLOAT = 'float';
14
15
    /**
16
     * Int operation.
17
     */
18
    const TYPE_INT = 'int';
19
20
    /**
21
     * Add two arbitrary precision numbers.
22
     *
23
     * @param string $leftOperand
24
     * @param string $rightOperand
25
     * @param int    $precision
26
     *
27
     * @return string
28
     */
29
    public function add(string $leftOperand, string $rightOperand, int $precision = 0): string;
30
31
    /**
32
     * Subtract two arbitrary precision numbers.
33
     *
34
     * @param string $leftOperand
35
     * @param string $rightOperand
36
     * @param int    $precision
37
     *
38
     * @return string
39
     */
40
    public function subtract(string $leftOperand, string $rightOperand, int $precision = 0): string;
41
42
    /**
43
     * Multiply two arbitrary precision numbers.
44
     *
45
     * @param string $leftOperand
46
     * @param string $rightOperand
47
     * @param int    $precision
48
     *
49
     * @return string
50
     */
51
    public function multiply(string $leftOperand, string $rightOperand, int $precision = 0): string;
52
53
    /**
54
     * Divide two arbitrary precision numbers.
55
     *
56
     * @param string $leftOperand
57
     * @param string $rightOperand
58
     * @param int    $precision
59
     *
60
     * @return string
61
     */
62
    public function divide(string $leftOperand, string $rightOperand, int $precision = 0): string;
63
64
    /**
65
     * Compare two arbitrary precision numbers.
66
     *
67
     * @param string $leftOperand
68
     * @param string $rightOperand
69
     * @param int    $precision
70
     *
71
     * @return string
72
     */
73
    public function compare(string $leftOperand, string $rightOperand, int $precision = 0): string;
74
75
    /**
76
     * Get modulus of an arbitrary precision number.
77
     *
78
     * @param string $operand
79
     * @param string $modulus
80
     * @param int    $precision
81
     *
82
     * @return string
83
     */
84
    public function modulus(string $operand, string $modulus, int $precision = 0): string;
85
86
    /**
87
     * Raise an arbitrary precision number to another.
88
     *
89
     * @param string $leftOperand
90
     * @param string $rightOperand
91
     * @param int    $precision
92
     *
93
     * @return string
94
     */
95
    public function power(string $leftOperand, string $rightOperand, int $precision = 0): string;
96
97
    /**
98
     * Get the square root of an arbitrary precision number.
99
     *
100
     * @param string $operand
101
     * @param int    $precision
102
     *
103
     * @return string
104
     */
105
    public function squareRoot(string $operand, int $precision = 0): string;
106
107
    /**
108
     * Returns absolute value of operand.
109
     *
110
     * @param string $operand
111
     *
112
     * @return string
113
     */
114
    public function absolute(string $operand): string;
115
116
    /**
117
     * Negates a number. Opposite of absolute/abs.
118
     *
119
     * @param string $operand
120
     *
121
     * @return string
122
     */
123
    public function negate(string $operand): string;
124
125
    /**
126
     * Returns the factorial of operand.
127
     *
128
     * @param string $operand
129
     *
130
     * @return string
131
     */
132
    public function factorial(string $operand): string;
133
134
    /**
135
     * Greatest common divisor.
136
     *
137
     * @param string $leftOperand
138
     * @param string $rightOperand
139
     *
140
     * @return string
141
     */
142
    public function gcd(string $leftOperand, string $rightOperand): string;
143
144
    /**
145
     * Calculates to the nth root.
146
     *
147
     * @param string $operand
148
     * @param int    $nth
149
     *
150
     * @return string
151
     */
152
    public function root(string $operand, int $nth): string;
153
154
    /**
155
     * Gets the next prime after operand.
156
     *
157
     * @param string $operand
158
     *
159
     * @return string
160
     */
161
    public function nextPrime(string $operand): string;
162
163
    /**
164
     * @param string $operand
165
     * @param int    $reps
166
     *
167
     * @return bool
168
     */
169
    public function isPrime(string $operand, int $reps = 10): bool;
170
171
    /**
172
     * Checks if operand is perfect square.
173
     *
174
     * @param string   $operand
175
     * @param int|null $precision
0 ignored issues
show
Documentation introduced by
Consider making the type for parameter $precision a bit more specific; maybe use integer.
Loading history...
176
     *
177
     * @return bool
178
     */
179
    public function isPerfectSquare(string $operand, int $precision = 0): bool;
180
181
    /**
182
     * The gamma function.
183
     *
184
     * @param string $operand
185
     *
186
     * @return string
187
     */
188
    public function gamma(string $operand): string;
189
190
    /**
191
     * The log-gamma function.
192
     *
193
     * @param string $operand
194
     *
195
     * @return string
196
     */
197
    public function logGamma(string $operand): string;
198
}
199