|
Ether Binder
Set of utilities for interacting with Ethereum and it's smart contracts with PHP, with generating ABI bindings and Ethereum-related types
|
Public Member Functions | |
| __construct (null|string|GMP $number=null, ?int $base=null) | |
| toInt () | |
| toString (bool $hex=false, bool $no0xHex=false, ?int $lpad0=null) | |
| toBin (?int $lpad0=null) | |
| __toString () | |
| raw () | |
| eq (OOGmp|int|GMP $b) | |
| gt (OOGmp|int|GMP $b) | |
| lt (OOGmp|int|GMP $b) | |
| ge (OOGmp|int|GMP $b) | |
| le (OOGmp|int|GMP $b) | |
| greaterThan (OOGmp|int|GMP $b) | |
| lessThan (OOGmp|int|GMP $b) | |
| lessOrEqual (OOGmp|int|GMP $b) | |
| greaterOrEqual (OOGmp|int|GMP $b) | |
| equal (OOGmp|int|GMP $b) | |
| add (OOGmp|int|GMP $b) | |
| sub (OOGmp|int|GMP $b) | |
| mul (OOGmp|int|GMP $b) | |
| div (OOGmp|int|GMP $b) | |
| max (OOGmp|int|GMP $b) | |
| min (OOGmp|int|GMP $b) | |
| mod (OOGmp|int|GMP $b) | |
| toHex () | |
| toBin () | |
Static Public Member Functions | |
| static | wrap (GMP $raw) |
| static | fromHex (string $hex) |
| static | fromBin (string $bin) |
OOGmp is a utility class that wraps PHP's GMP library for working with arbitrary-size integers. It provides an easy-to-use, object-oriented API for Ethereum-related operations and offers a chainable arithmetic operations API.
Arithmetic Functions: The class provides basic arithmetic operations like addition (add), subtraction (sub), multiplication (mul), and division (div). These methods support automatic type normalization, allowing you to pass in OOGmp|int|GMP as arguments.
Comparison Functions: Standard comparison operations are included, such as eq (equals), lt (less than), gt (greater than), etc. Aliases are also available, like eq - equal. These functions also support automatic type normalization.
| M8B\EtherBinder\Utils\OOGmp::__construct | ( | null|string|GMP | $number = null, |
| ?int | $base = null ) |
Initializes a new OOGmp object.
| null | string | GMP | $number | The initial number value as null, string, or GMP object. |
| int | null | $base | The base for string input. Defaults attempts to guess, if $number has 0x prefix, it defaults to 16, otherwise if it has any of a-f characters, it defaults to 16, otherwise it defaults to 10. Be very cautions when relying on that detection as non-0x-prefixed hex that happens to not have any a-f will be mistreated as base = 10. |
|
static |
Static alias to constructor to fulfil HashSerializable interface
| string | $bin |
Implements M8B\EtherBinder\Common\HashSerializable.
|
static |
Static alias to constructor to fulfil HashSerializable interface
| string | $hex |
Implements M8B\EtherBinder\Common\HashSerializable.
| M8B\EtherBinder\Utils\OOGmp::raw | ( | ) |
Returns the raw GMP object.
|
inherited |
Implemented in M8B\EtherBinder\Common\Hash.
| M8B\EtherBinder\Utils\OOGmp::toBin | ( | ?int | $lpad0 = null | ) |
Converts the internal GMP number to a binary string.
| int | null | $lpad0 | Number of zeros to pad on the left. |
| InvalidHexException |
| M8B\EtherBinder\Utils\OOGmp::toHex | ( | ) |
Alias to toString() to fulfil HashSerializable interface
Implements M8B\EtherBinder\Common\HashSerializable.
| M8B\EtherBinder\Utils\OOGmp::toInt | ( | ) |
Converts the internal GMP number to an integer.
| EthBinderRuntimeException | If the GMP number is larger than PHP_INT_MAX. |
| M8B\EtherBinder\Utils\OOGmp::toString | ( | bool | $hex = false, |
| bool | $no0xHex = false, | ||
| ?int | $lpad0 = null ) |
Converts the internal GMP number to a string.
| bool | $hex | If true, returns a hexadecimal string. Otherwise, returns a decimal string. |
| bool | $no0xHex | If true and $hex is true, omits the "0x" prefix. |
| int | null | $lpad0 | Number of zeros to pad on the left. |
|
static |
Wraps a raw GMP object into an OOGmp instance.
| GMP | $raw | The GMP object to be wrapped. |