| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <?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\IntegerFormatter;
- class AddressFormatter implements IFormatter
- {
- /**
- * format
- * to do: iban
- *
- * @param mixed $value
- * @return string
- */
- public static function format($value)
- {
- $value = (string) $value;
- if (Utils::isAddress($value)) {
- $value = mb_strtolower($value);
- if (Utils::isZeroPrefixed($value)) {
- return $value;
- }
- return '0x' . $value;
- }
- $value = IntegerFormatter::format($value, 40);
- return '0x' . $value;
- }
- }
|