Eth protocol version.

This commit is contained in:
sc0Vu 2018-01-11 16:46:08 +08:00
parent 2baac410de
commit 26b6844f44

View File

@ -0,0 +1,91 @@
<?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\Methods\Eth;
use InvalidArgumentException;
use Web3\Methods\IMethod;
use Web3\Methods\JSONRPC;
use Web3\Formatters\BigNumberFormatter;
class ProtocolVersion extends JSONRPC implements IMethod
{
/**
* inputFormatters
*
* @var array
*/
protected $inputFormatters = [];
/**
* outputFormatters
*
* @var array
*/
protected $outputFormatters = [
BigNumberFormatter::class
];
/**
* construct
*
* @param string $method
* @param array $arguments
* @return void
*/
// public function __construct($method='', $arguments=[])
// {
// parent::__construct($method, $arguments);
// }
/**
* getInputFormatters
*
* @return array
*/
public function getInputFormatters()
{
return $this->inputFormatters;
}
/**
* getOutputFormatters
*
* @return array
*/
public function getOutputFormatters()
{
return $this->outputFormatters;
}
/**
* transform
*
* @param array $params
* @param array $rules
* @return array
*/
public function transform($params, $rules)
{
if (!is_array($params)) {
throw new InvalidArgumentException('Please use array params when call transform.');
}
if (!is_array($rules)) {
throw new InvalidArgumentException('Please use array rules when call transform.');
}
foreach ($params as $key => $param) {
if (isset($rules[$key])) {
$params[$key] = call_user_func([$rules[$key], 'format'], $param);
}
}
return $params;
}
}