toString()

This commit is contained in:
sc0Vu 2018-01-09 17:45:13 +08:00
parent 48d00a2641
commit 917f08e74f

View File

@ -11,6 +11,7 @@
namespace Web3; namespace Web3;
use RuntimeException;
use InvalidArgumentException; use InvalidArgumentException;
use stdClass; use stdClass;
use kornrunner\Keccak; use kornrunner\Keccak;
@ -214,6 +215,22 @@ class Utils
return '0x' . $hash; return '0x' . $hash;
} }
/**
* toString
*
* @param mixed $value
* @return string
*/
public function toString($value)
{
try {
$value = (string) $value;
} catch (\Exception $e) {
throw new RuntimeException('Cannot transform value to string!');
}
return $value;
}
/** /**
* toWei * toWei
* Change number from unit to wei. * Change number from unit to wei.