stripZero
This commit is contained in:
parent
de19210492
commit
fce712ddcd
@ -83,6 +83,21 @@ class Utils
|
|||||||
return (strpos($value, '0x') === 0);
|
return (strpos($value, '0x') === 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* stripZero
|
||||||
|
*
|
||||||
|
* @param string $value
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function stripZero($value)
|
||||||
|
{
|
||||||
|
if (self::isZeroPrefixed($value)) {
|
||||||
|
$count = 1;
|
||||||
|
return str_replace('0x', '', $value, $count);
|
||||||
|
}
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sha3
|
* sha3
|
||||||
* keccak256
|
* keccak256
|
||||||
|
@ -79,6 +79,22 @@ class UtilsTest extends TestCase
|
|||||||
$this->assertEquals($isPrefixed, true);
|
$this->assertEquals($isPrefixed, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* testStripZero
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testStripZero()
|
||||||
|
{
|
||||||
|
$str = Utils::stripZero($this->testHex);
|
||||||
|
|
||||||
|
$this->assertEquals($str, $this->testHex);
|
||||||
|
|
||||||
|
$str = Utils::stripZero('0x' . $this->testHex);
|
||||||
|
|
||||||
|
$this->assertEquals($str, $this->testHex);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testSha3
|
* testSha3
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user