From 9f4614781eed1ea292299688a296c250aa9105a9 Mon Sep 17 00:00:00 2001 From: sc0Vu Date: Fri, 26 Jan 2018 17:49:29 +0800 Subject: [PATCH] Post formatter. --- src/Formatters/PostFormatter.php | 37 ++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/Formatters/PostFormatter.php diff --git a/src/Formatters/PostFormatter.php b/src/Formatters/PostFormatter.php new file mode 100644 index 0000000..cf5c49f --- /dev/null +++ b/src/Formatters/PostFormatter.php @@ -0,0 +1,37 @@ + + * + * @author Peter Lai + * @license MIT + */ + +namespace Web3\Formatters; + +use InvalidArgumentException; +use Web3\Utils; +use Web3\Formatters\IFormatter; +use Web3\Formatters\QuantityFormatter; + +class PostFormatter implements IFormatter +{ + /** + * format + * + * @param mixed $value + * @return string + */ + public static function format($value) + { + if (isset($value['priority'])) { + $value['priority'] = QuantityFormatter::format($value['priority']); + } + if (isset($value['ttl'])) { + $value['ttl'] = QuantityFormatter::format($value['ttl']); + } + return $value; + } +} \ No newline at end of file