Skip to content

Commit

Permalink
Refactor: Extract string cast overloading to base class
Browse files Browse the repository at this point in the history
  • Loading branch information
thekid committed May 29, 2017
1 parent 4f52421 commit 7a17960
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 19 deletions.
9 changes: 0 additions & 9 deletions src/main/php/math/BigFloat.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,4 @@ public function round($precision= 0) {
: ('-' === $this->num{0} ? bcsub($this->num, $a, $precision) : bcadd($this->num, $a, $precision))
);
}

/**
* String cast overloading
*
* @return string
*/
public function __toString() {
return $this->num;
}
}
9 changes: 0 additions & 9 deletions src/main/php/math/BigInt.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,15 +286,6 @@ protected static function bytesOf($n) {
}
return ltrim($value, "\0");
}

/**
* String cast overloading
*
* @return string
*/
public function __toString() {
return $this->num;
}

/**
* Returns an byte representing this big integer
Expand Down
5 changes: 4 additions & 1 deletion src/main/php/math/BigNum.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,14 @@ public function intValue() { return (int)substr($this->num, 0, strcspn($this->nu
*/
public function doubleValue() { return (double)$this->num; }

/** @return string */
public function __toString() { return $this->num; }

/** @return string */
public function toString() { return nameof($this).'('.$this->num.')'; }

/** @return string */
public function hashCode() { return $this->num; }
public function hashCode() { return (string)$this->num; }

/**
* Compare another value to this bignum
Expand Down

0 comments on commit 7a17960

Please sign in to comment.