| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <?php
- /**
- * This file is part of web3.php package.
- *
- * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
- *
- * @author Peter Lai <alk03073135@gmail.com>
- * @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;
- }
- }
|