diff --git a/examples/exampleBase.php b/examples/exampleBase.php index 9f335f1..ca18e2c 100644 --- a/examples/exampleBase.php +++ b/examples/exampleBase.php @@ -4,4 +4,4 @@ require('../vendor/autoload.php'); use Web3\Web3; -$web3 = new Web3('http://192.168.99.100:8545'); \ No newline at end of file +$web3 = new Web3('http://192.168.99.100:8545/'); \ No newline at end of file diff --git a/src/Formatters/BooleanFormatter.php b/src/Formatters/BooleanFormatter.php index f6cd328..1107cf0 100644 --- a/src/Formatters/BooleanFormatter.php +++ b/src/Formatters/BooleanFormatter.php @@ -21,13 +21,10 @@ class BooleanFormatter implements IFormatter * format * * @param mixed $value - * @return int + * @return bool */ public static function format($value) { - if (!is_bool($value)) { - throw new InvalidArgumentException('The value to inputFormat function must be boolean.'); - } - return (int) $value; + return (bool) $value; } } \ No newline at end of file diff --git a/test/unit/BooleanFormatterTest.php b/test/unit/BooleanFormatterTest.php index b0da5b4..24c7d4a 100644 --- a/test/unit/BooleanFormatterTest.php +++ b/test/unit/BooleanFormatterTest.php @@ -36,12 +36,15 @@ class BooleanFormatterTest extends TestCase $formatter = $this->formatter; $boolean = $formatter->format(true); - $this->assertEquals($boolean, 1); + $this->assertEquals($boolean, true); + + $boolean = $formatter->format(1); + $this->assertEquals($boolean, true); $boolean = $formatter->format(false); - $this->assertEquals($boolean, 0); + $this->assertEquals($boolean, false); - $this->expectException(InvalidArgumentException::class); - $boolean = $formatter->format('boolean'); + $boolean = $formatter->format(0); + $this->assertEquals($boolean, false); } } \ No newline at end of file