35 lines
684 B
PHP
35 lines
684 B
PHP
<?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 Web3\Formatters;
|
|
|
|
use InvalidArgumentException;
|
|
use Web3\Utils;
|
|
use Web3\Formatters\IFormatter;
|
|
use Web3\Validators\TagValidator;
|
|
use Web3\Formatters\QuantityFormatter;
|
|
|
|
class OptionalQuantityFormatter implements IFormatter
|
|
{
|
|
/**
|
|
* format
|
|
*
|
|
* @param mixed $value
|
|
* @return string
|
|
*/
|
|
public static function format($value)
|
|
{
|
|
if (TagValidator::validate($value)) {
|
|
return $value;
|
|
}
|
|
return QuantityFormatter::format($value);
|
|
}
|
|
} |