diff --git a/src/Formatters/BooleanFormatter.php b/src/Formatters/BooleanFormatter.php new file mode 100644 index 0000000..f6cd328 --- /dev/null +++ b/src/Formatters/BooleanFormatter.php @@ -0,0 +1,33 @@ + + * + * @author Peter Lai + * @license MIT + */ + +namespace Web3\Formatters; + +use InvalidArgumentException; +use Web3\Utils; +use Web3\Formatters\IFormatter; + +class BooleanFormatter implements IFormatter +{ + /** + * format + * + * @param mixed $value + * @return int + */ + public static function format($value) + { + if (!is_bool($value)) { + throw new InvalidArgumentException('The value to inputFormat function must be boolean.'); + } + return (int) $value; + } +} \ No newline at end of file