From 69af8e7e5d1ab6edb09d73c675829c4f522d2d4d Mon Sep 17 00:00:00 2001 From: Hugo Rafael Azevedo Date: Sat, 25 May 2019 14:06:44 +0100 Subject: [PATCH] Added conversions to ReadonlyBoolean datatypes. --- src/Scalar/AbstractWriteFloat.php | 14 -------------- src/Scalar/AbstractWriteInteger.php | 14 -------------- src/Scalar/ImmutableInteger.php | 1 - src/Scalar/MutableFloat.php | 1 - src/Scalar/MutableInteger.php | 2 -- src/Scalar/ReadonlyFloat.php | 14 +++++++++++++- src/Scalar/ReadonlyInteger.php | 14 +++++++++++++- 7 files changed, 26 insertions(+), 34 deletions(-) diff --git a/src/Scalar/AbstractWriteFloat.php b/src/Scalar/AbstractWriteFloat.php index 5b306c9..92714fd 100644 --- a/src/Scalar/AbstractWriteFloat.php +++ b/src/Scalar/AbstractWriteFloat.php @@ -65,18 +65,4 @@ protected function doDivide(float $value): float { return ($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::fromFloat($this->value); - } } diff --git a/src/Scalar/AbstractWriteInteger.php b/src/Scalar/AbstractWriteInteger.php index 270cc8e..67a8946 100644 --- a/src/Scalar/AbstractWriteInteger.php +++ b/src/Scalar/AbstractWriteInteger.php @@ -65,18 +65,4 @@ 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); - } } diff --git a/src/Scalar/ImmutableInteger.php b/src/Scalar/ImmutableInteger.php index fd533a8..834456e 100644 --- a/src/Scalar/ImmutableInteger.php +++ b/src/Scalar/ImmutableInteger.php @@ -161,5 +161,4 @@ public function toFloat(): ImmutableFloat { return ImmutableFloat::fromString($this->__toString()); } - //public function toBoolean(): ImmutableBoolean; } diff --git a/src/Scalar/MutableFloat.php b/src/Scalar/MutableFloat.php index 26c115a..3f2b258 100644 --- a/src/Scalar/MutableFloat.php +++ b/src/Scalar/MutableFloat.php @@ -163,5 +163,4 @@ public function toInteger(): MutableInteger { return MutableInteger::fromString($this->__toString()); } - //public function toBoolean(): MutableBoolean; } diff --git a/src/Scalar/MutableInteger.php b/src/Scalar/MutableInteger.php index e1bbf87..fd17c1c 100644 --- a/src/Scalar/MutableInteger.php +++ b/src/Scalar/MutableInteger.php @@ -163,6 +163,4 @@ public function toFloat(): MutableFloat { return MutableFloat::fromString($this->__toString()); } - - //public function toBoolean(): MutableBoolean; } diff --git a/src/Scalar/ReadonlyFloat.php b/src/Scalar/ReadonlyFloat.php index 0286ade..f2acb0b 100644 --- a/src/Scalar/ReadonlyFloat.php +++ b/src/Scalar/ReadonlyFloat.php @@ -109,5 +109,17 @@ public function toInteger(): ReadonlyInteger return ReadonlyInteger::fromString($this->__toString()); } - //public function toBoolean(): ReandonlyBoolean; + /** + * 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::fromFloat($this->value); + } } diff --git a/src/Scalar/ReadonlyInteger.php b/src/Scalar/ReadonlyInteger.php index cb1bd5a..4f1b27c 100644 --- a/src/Scalar/ReadonlyInteger.php +++ b/src/Scalar/ReadonlyInteger.php @@ -92,5 +92,17 @@ public function toFloat(): ReadonlyFloat return ReadonlyFloat::fromInteger($this->value); } - //public function toBoolean(): ReandonlyBoolean; + /** + * Converts integer'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); + } }