Net use EthMethod
This commit is contained in:
parent
fa63012c06
commit
05a1a638cf
@ -12,10 +12,9 @@
|
||||
namespace Web3\Methods\Net;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use Web3\Methods\IMethod;
|
||||
use Web3\Methods\JSONRPC;
|
||||
use Web3\Methods\EthMethod;
|
||||
|
||||
class Listening extends JSONRPC implements IMethod
|
||||
class Listening extends EthMethod
|
||||
{
|
||||
/**
|
||||
* inputFormatters
|
||||
@ -31,6 +30,13 @@ class Listening extends JSONRPC implements IMethod
|
||||
*/
|
||||
protected $outputFormatters = [];
|
||||
|
||||
/**
|
||||
* defaultValues
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $defaultValues = [];
|
||||
|
||||
/**
|
||||
* construct
|
||||
*
|
||||
@ -42,47 +48,4 @@ class Listening extends JSONRPC implements IMethod
|
||||
// {
|
||||
// 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;
|
||||
}
|
||||
}
|
@ -12,11 +12,10 @@
|
||||
namespace Web3\Methods\Net;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use Web3\Methods\IMethod;
|
||||
use Web3\Methods\JSONRPC;
|
||||
use Web3\Methods\EthMethod;
|
||||
use Web3\Formatters\BigNumberFormatter;
|
||||
|
||||
class PeerCount extends JSONRPC implements IMethod
|
||||
class PeerCount extends EthMethod
|
||||
{
|
||||
/**
|
||||
* inputFormatters
|
||||
@ -34,6 +33,13 @@ class PeerCount extends JSONRPC implements IMethod
|
||||
BigNumberFormatter::class
|
||||
];
|
||||
|
||||
/**
|
||||
* defaultValues
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $defaultValues = [];
|
||||
|
||||
/**
|
||||
* construct
|
||||
*
|
||||
@ -45,47 +51,4 @@ class PeerCount extends JSONRPC implements IMethod
|
||||
// {
|
||||
// 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;
|
||||
}
|
||||
}
|
@ -12,10 +12,9 @@
|
||||
namespace Web3\Methods\Net;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use Web3\Methods\IMethod;
|
||||
use Web3\Methods\JSONRPC;
|
||||
use Web3\Methods\EthMethod;
|
||||
|
||||
class Version extends JSONRPC implements IMethod
|
||||
class Version extends EthMethod
|
||||
{
|
||||
/**
|
||||
* inputFormatters
|
||||
@ -31,6 +30,13 @@ class Version extends JSONRPC implements IMethod
|
||||
*/
|
||||
protected $outputFormatters = [];
|
||||
|
||||
/**
|
||||
* defaultValues
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $defaultValues = [];
|
||||
|
||||
/**
|
||||
* construct
|
||||
*
|
||||
@ -42,47 +48,4 @@ class Version extends JSONRPC implements IMethod
|
||||
// {
|
||||
// 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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user