Ethereum PHP
PHP interface to Ethereum JSON-RPC API.
EthB.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Ethereum\DataType;
4 
6 
10 class EthB extends EthQ
11 {
28  public function validate($val, array $params)
29  {
30  $params['abi'] = 'uint8';
31 
32  if (is_bool($val)) {
33  $val = (int)$val;
34  }
35 
36  $big_int = parent::validate($val, $params = ['abi' => 'uint8']);
37  $int = (int)$big_int->toString();
38  if (!($int === 1 || $int === 0)) {
39  throw new \InvalidArgumentException('Can not decode bool value : ' . $val);
40  }
41  $this->abi = 'bool';
42 
43  return $big_int;
44  }
45 
52  public function val()
53  {
54  return (bool)$this->value->toString();
55  }
56 }
validate($val, array $params)
Definition: EthB.php:28