* * @author Peter Lai * @license MIT */ namespace blockchain\web3\src\Formatters; use InvalidArgumentException; use blockchain\web3\src\Utils; use blockchain\web3\src\Formatters\IFormatter; use blockchain\web3\src\Formatters\HexFormatter; use blockchain\web3\src\Formatters\QuantityFormatter; class TransactionFormatter implements IFormatter { /** * format * * @param mixed $value * @return string */ public static function format($value) { if (isset($value['gas'])) { $value['gas'] = QuantityFormatter::format($value['gas']); } if (isset($value['gasPrice'])) { $value['gasPrice'] = QuantityFormatter::format($value['gasPrice']); } if (isset($value['value'])) { $value['value'] = QuantityFormatter::format($value['value']); } if (isset($value['data'])) { $value['data'] = HexFormatter::format($value['data']); } if (isset($value['nonce'])) { $value['nonce'] = QuantityFormatter::format($value['nonce']); } return $value; } }