Skip to content

Commit 7a17960

Browse files
committed
Refactor: Extract string cast overloading to base class
1 parent 4f52421 commit 7a17960

File tree

3 files changed

+4
-19
lines changed

3 files changed

+4
-19
lines changed

src/main/php/math/BigFloat.class.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,4 @@ public function round($precision= 0) {
114114
: ('-' === $this->num{0} ? bcsub($this->num, $a, $precision) : bcadd($this->num, $a, $precision))
115115
);
116116
}
117-
118-
/**
119-
* String cast overloading
120-
*
121-
* @return string
122-
*/
123-
public function __toString() {
124-
return $this->num;
125-
}
126117
}

src/main/php/math/BigInt.class.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -286,15 +286,6 @@ protected static function bytesOf($n) {
286286
}
287287
return ltrim($value, "\0");
288288
}
289-
290-
/**
291-
* String cast overloading
292-
*
293-
* @return string
294-
*/
295-
public function __toString() {
296-
return $this->num;
297-
}
298289

299290
/**
300291
* Returns an byte representing this big integer

src/main/php/math/BigNum.class.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,14 @@ public function intValue() { return (int)substr($this->num, 0, strcspn($this->nu
6868
*/
6969
public function doubleValue() { return (double)$this->num; }
7070

71+
/** @return string */
72+
public function __toString() { return $this->num; }
73+
7174
/** @return string */
7275
public function toString() { return nameof($this).'('.$this->num.')'; }
7376

7477
/** @return string */
75-
public function hashCode() { return $this->num; }
78+
public function hashCode() { return (string)$this->num; }
7679

7780
/**
7881
* Compare another value to this bignum

0 commit comments

Comments
 (0)