From 620c14de5a5dce7fe7b0d3f6726834694124535d Mon Sep 17 00:00:00 2001 From: Hugo Rafael Azevedo Date: Sat, 25 May 2019 14:01:17 +0100 Subject: [PATCH] Added toBoolean() shared method. --- src/Scalar/AbstractWriteInteger.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Scalar/AbstractWriteInteger.php b/src/Scalar/AbstractWriteInteger.php index 67a8946..270cc8e 100644 --- a/src/Scalar/AbstractWriteInteger.php +++ b/src/Scalar/AbstractWriteInteger.php @@ -65,4 +65,18 @@ protected function doDivide(int $value): int { return \intval($this->value / $value); } + + /** + * Converts float's instance to an equivalent boolean instance. + * + * A ReadonlyBoolean will be returned, as Booleans don't require Immutable and Mutable + * distinctions. + * + * @since 1.0.0 + * @return ReadonlyBoolean + */ + public function toBoolean(): ReadonlyBoolean + { + return ReadonlyBoolean::fromInteger($this->value); + } }