Ethereum PHP
PHP interface to Ethereum JSON-RPC API.
EthQ Class Reference
+ Inheritance diagram for EthQ:
+ Collaboration diagram for EthQ:

Public Member Functions

 __construct ($val, array $params=[])
 
 validate ($val, array $params)
 
 hexVal ()
 
 hexValUnpadded ()
 
 getLength ($abi)
 
 isNegative ($abi=false)
 
 isLargeNumber (Math_BigInteger $val)
 
 val ()
 
 encodedHexVal ()
 
 isNotNull ()
 
 getAbi ()
 
- Public Member Functions inherited from EthD
const const __construct ($val, array $params=[])
 
 convertByAbi ($abiType)
 
 validate ($val, array $params)
 
 validateHexString ($val)
 
 convertTo ($type)
 
 toArray ()
 
 hexVal ()
 
 encodedHexVal ()
 
 val ()
 
- Public Member Functions inherited from EthDataType
 getProperty (string $property='value', bool $returnHexVal=false)
 
 setValue ($val, array $params=[])
 
 getClassName ()
 

Static Public Member Functions

static getValidLengths ()
 
static getDataLengthType ()
 
- Static Public Member Functions inherited from EthD
static getPrimitiveTypes ()
 
static isPrimitive ()
 
static typeMap (string $type)
 
static reverseTypeMap ($class_name)
 
static getSchemaType ()
 
static getTypeArray ()
 
- Static Public Member Functions inherited from EthDataType
const static getClassByAbi (string $abiType)
 
static getDataLengthType ()
 
static isPrimitive ()
 
static getTypeClass (string $type, bool $typed_constructor=false)
 
static getAllTypeClasses ()
 
- Static Public Member Functions inherited from EthereumStatic
static getMethodSignature ($input)
 
static phpKeccak256 ($string)
 
static sha3 ($string)
 
static isValidFunction ($input)
 
static getDefinition ()
 
static isValidHexQuantity ($str)
 
static isValidHexData ($str)
 
static isValidAddress ($address, $throw=false)
 
static hasHexPrefix ($str)
 
static removeHexPrefix ($str)
 
static ensureHexPrefix ($str)
 
static convertCurrency (float $amount, string $from='wei', string $to='ether')
 

Public Attributes

 $value
 
const HEXPADDING = 64
 

Protected Member Functions

 getAbiFromNumber (Math_BigInteger $number)
 
 validateAbi ($abi)
 

Static Protected Member Functions

static splitAbi ($abi)
 

Protected Attributes

 $abi
 
- Protected Attributes inherited from EthD
 $value
 
 $abi
 

Detailed Description

Numeric data.

Definition at line 14 of file EthQ.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $val,
array  $params = [] 
)

Overriding constructor.

Parameters
string | int$valHexadecimal or number value.
array$paramsArray with optional parameters. Add Abi type $params['abi'] = 'unint8'.
Exceptions
Exception

Definition at line 43 of file EthQ.php.

Member Function Documentation

◆ encodedHexVal()

encodedHexVal ( )
Returns
string

Definition at line 339 of file EthQ.php.

References EthQ\hexVal().

+ Here is the call graph for this function:

◆ getAbi()

getAbi ( )

Implement Integer value.

Returns
int|string Return a PHP integer. If $val > PHP_INT_MAX we return a string containing the integer.

Definition at line 362 of file EthQ.php.

References EthQ\$abi.

◆ getAbiFromNumber()

getAbiFromNumber ( Math_BigInteger  $number)
protected

getAbiFromIntVal().

Parameters
Math_BigInteger$number"0x" prefixed Hexadecimal value.
Returns
string Abi type.

Definition at line 146 of file EthQ.php.

References EthQ\getValidLengths().

Referenced by EthQ\validate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDataLengthType()

static getDataLengthType ( )
static
Returns
string|int

Implements EthDataTypeInterface.

Definition at line 384 of file EthQ.php.

◆ getLength()

getLength (   $abi)

Implement getLength().

Definition at line 278 of file EthQ.php.

References EthQ\$abi, and EthQ\splitAbi().

Referenced by EthQ\validate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getValidLengths()

static getValidLengths ( )
static

Valid number lengths.

Array of valid M's, where % 8 == 0 && 8 <= M <= 256

Returns
array Array of valid integer lengths for (u)int and (u)fixed types.

Definition at line 375 of file EthQ.php.

Referenced by EthQ\getAbiFromNumber().

+ Here is the caller graph for this function:

◆ hexVal()

hexVal ( )

Implement hex value.

Exceptions
Exception

Definition at line 246 of file EthQ.php.

References EthQ\$value.

Referenced by EthQ\encodedHexVal().

+ Here is the caller graph for this function:

◆ hexValUnpadded()

hexValUnpadded ( )

Implement hex value.

Exceptions
Exception

Definition at line 270 of file EthQ.php.

◆ isLargeNumber()

isLargeNumber ( Math_BigInteger  $val)

Check if number is large.

Parameters
Math_BigInteger$valMath_BigInteger value.
Returns
bool Return TRUE if number > PHP_INT_MAX.

Definition at line 314 of file EthQ.php.

Referenced by EthQ\val().

+ Here is the caller graph for this function:

◆ isNegative()

isNegative (   $abi = false)

Implement hex value.

Definition at line 288 of file EthQ.php.

References EthQ\$abi, and EthQ\splitAbi().

+ Here is the call graph for this function:

◆ isNotNull()

isNotNull ( )

Checks if value is not null.

Returns
bool

Definition at line 349 of file EthQ.php.

◆ splitAbi()

static splitAbi (   $abi)
staticprotected

Split abi type into length and intType.

Definition at line 224 of file EthQ.php.

References EthQ\$abi.

Referenced by EthQ\getLength(), EthQ\isNegative(), and EthQ\validateAbi().

+ Here is the caller graph for this function:

◆ val()

val ( )

Implement Integer value.

Returns
int|string Return a PHP integer. If $val > PHP_INT_MAX we return a string containing the integer.

Definition at line 326 of file EthQ.php.

References EthQ\isLargeNumber().

+ Here is the call graph for this function:

◆ validate()

validate (   $val,
array  $params 
)

Implement validation.

Parameters
string | number$val"0x"prefixed hexadecimal or number value.
array$paramsOnly $param['abi'] is relevant.
Exceptions
ExceptionIf things are wrong.
Returns
Math_BigInteger.

Definition at line 61 of file EthQ.php.

References EthQ\$abi, EthQ\getAbiFromNumber(), EthQ\getLength(), EthereumStatic\hasHexPrefix(), and EthQ\validateAbi().

+ Here is the call graph for this function:

◆ validateAbi()

validateAbi (   $abi)
protected

Validate ABI.

See: https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI#types.

Parameters
string$abiValid Abi for number. E.g uint8, int160 ...
Exceptions
InvalidArgumentExceptionIf Abi don't match definition.
Returns
bool TRUE if abi matches definition.

Definition at line 193 of file EthQ.php.

References EthQ\$abi, and EthQ\splitAbi().

Referenced by EthQ\validate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ $abi

string $abi
protected

◆ $value

$value

Definition at line 20 of file EthQ.php.

Referenced by EthBlockParam\hexVal(), EthQ\hexVal(), EthBlockParam\isTag(), and EthBlockParam\val().

◆ HEXPADDING

const HEXPADDING = 64

Definition at line 31 of file EthQ.php.


The documentation for this class was generated from the following file: