1 | <?php |
||
12 | class BigInteger |
||
13 | { |
||
14 | /** |
||
15 | * The value represented as a string. |
||
16 | * |
||
17 | * @var string |
||
18 | */ |
||
19 | private $value; |
||
20 | |||
21 | /** |
||
22 | * A flag that indicates whether or not the state of this object can be changed. |
||
23 | * |
||
24 | * @var bool |
||
25 | */ |
||
26 | private $mutable; |
||
27 | |||
28 | /** |
||
29 | * Initializes a new instance of this class. |
||
30 | * |
||
31 | * @param string|int|BigInteger $value The value to set. |
||
32 | * @param bool $mutable Whether or not the state of this object can be changed. |
||
33 | */ |
||
34 | 67 | public function __construct($value = 0, $mutable = true) |
|
40 | |||
41 | /** |
||
42 | * Gets the value of the big integer. |
||
43 | * |
||
44 | * @return string |
||
45 | */ |
||
46 | 52 | public function getValue() |
|
50 | |||
51 | /** |
||
52 | * Sets the value. |
||
53 | * |
||
54 | * @param string $value The value to set. |
||
55 | * @return BigInteger |
||
56 | */ |
||
57 | 5 | public function setValue($value) |
|
65 | |||
66 | /** |
||
67 | * Converts the value to an absolute number. |
||
68 | * |
||
69 | * @return BigInteger |
||
70 | */ |
||
71 | 5 | public function abs() |
|
77 | |||
78 | /** |
||
79 | * Adds the given value to this value. |
||
80 | * |
||
81 | * @param string $value The value to add. |
||
82 | * @return BigInteger |
||
83 | */ |
||
84 | 6 | public function add($value) |
|
94 | |||
95 | /** |
||
96 | * Compares this number and the given number. |
||
97 | * |
||
98 | * @return int Returns -1 is the number is less than this number. 0 if equal and 1 when greater. |
||
99 | */ |
||
100 | 4 | public function cmp($value) |
|
117 | |||
118 | /** |
||
119 | * Divides this value by the given value. |
||
120 | * |
||
121 | * @param string $value The value to divide by. |
||
122 | * @return BigInteger |
||
123 | */ |
||
124 | 9 | public function divide($value) |
|
134 | |||
135 | /** |
||
136 | * Calculates factorial of this value. |
||
137 | * |
||
138 | * @return BigInteger |
||
139 | */ |
||
140 | 3 | public function factorial() |
|
146 | |||
147 | /** |
||
148 | * Performs a modulo operation with the given number. |
||
149 | * |
||
150 | * @param string $value The value to perform a modulo operation with. |
||
151 | * @return BigInteger |
||
152 | */ |
||
153 | 6 | public function mod($value) |
|
163 | |||
164 | /** |
||
165 | * Multiplies the given value with this value. |
||
166 | * |
||
167 | * @param string $value The value to multiply with. |
||
168 | * @return BigInteger |
||
169 | */ |
||
170 | 6 | public function multiply($value) |
|
180 | |||
181 | /** |
||
182 | * Negates the value. |
||
183 | * |
||
184 | * @return BigInteger |
||
185 | */ |
||
186 | 3 | public function negate() |
|
192 | |||
193 | /** |
||
194 | * Performs a power operation with the given number. |
||
195 | * |
||
196 | * @param string $value The value to perform a power operation with. |
||
197 | * @return BigInteger |
||
198 | */ |
||
199 | 6 | public function pow($value) |
|
207 | |||
208 | /** |
||
209 | * Subtracts the given value from this value. |
||
210 | * |
||
211 | * @param string $value The value to subtract. |
||
212 | * @return BigInteger |
||
213 | */ |
||
214 | 6 | public function subtract($value) |
|
224 | |||
225 | /** |
||
226 | * Checks if this object is mutable. |
||
227 | * |
||
228 | * @return bool |
||
229 | */ |
||
230 | 52 | public function isMutable() |
|
234 | |||
235 | /** |
||
236 | * Converts this class to a string. |
||
237 | * |
||
238 | * @return string |
||
239 | */ |
||
240 | 11 | public function toString() |
|
244 | |||
245 | /** |
||
246 | * Converts this class to a string. |
||
247 | * |
||
248 | * @return string |
||
249 | */ |
||
250 | 11 | public function __toString() |
|
254 | |||
255 | /** |
||
256 | * A helper method to assign the given value. |
||
257 | * |
||
258 | * @param int|string|BigInteger $value The value to assign. |
||
259 | * @return BigInteger |
||
260 | */ |
||
261 | 44 | private function assignValue($value) |
|
273 | |||
274 | /** |
||
275 | * A helper method to set the value on this class. |
||
276 | * |
||
277 | * @param int|string|BigInteger $value The value to assign. |
||
278 | * @return BigInteger |
||
279 | */ |
||
280 | 67 | private function internalSetValue($value) |
|
288 | |||
289 | /** |
||
290 | * Checks if the given value is valid. |
||
291 | * |
||
292 | * @param int|string $value The value to check. |
||
293 | * @throws InvalidArgumentException Thrown when the value is invalid. |
||
294 | */ |
||
295 | 67 | private function checkValue(&$value) |
|
307 | } |
||
308 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.