stripZero

This commit is contained in:
sc0Vu 2017-12-22 18:12:47 +08:00
parent de19210492
commit fce712ddcd
2 changed files with 31 additions and 0 deletions

View File

@ -83,6 +83,21 @@ class Utils
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
* keccak256

View File

@ -79,6 +79,22 @@ class UtilsTest extends TestCase
$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
*