aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/brick/math/src/BigRational.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/brick/math/src/BigRational.php')
-rw-r--r--vendor/brick/math/src/BigRational.php34
1 files changed, 34 insertions, 0 deletions
diff --git a/vendor/brick/math/src/BigRational.php b/vendor/brick/math/src/BigRational.php
index 7fbabd7f1..bee094f73 100644
--- a/vendor/brick/math/src/BigRational.php
+++ b/vendor/brick/math/src/BigRational.php
@@ -452,6 +452,40 @@ final class BigRational extends BigNumber
}
/**
+ * This method is required for serializing the object and SHOULD NOT be accessed directly.
+ *
+ * @internal
+ *
+ * @return array{numerator: BigInteger, denominator: BigInteger}
+ */
+ public function __serialize(): array
+ {
+ return ['numerator' => $this->numerator, 'denominator' => $this->denominator];
+ }
+
+ /**
+ * This method is only here to allow unserializing the object and cannot be accessed directly.
+ *
+ * @internal
+ * @psalm-suppress RedundantPropertyInitializationCheck
+ *
+ * @param array{numerator: BigInteger, denominator: BigInteger} $data
+ *
+ * @return void
+ *
+ * @throws \LogicException
+ */
+ public function __unserialize(array $data): void
+ {
+ if (isset($this->numerator)) {
+ throw new \LogicException('__unserialize() is an internal function, it must not be called directly.');
+ }
+
+ $this->numerator = $data['numerator'];
+ $this->denominator = $data['denominator'];
+ }
+
+ /**
* This method is required by interface Serializable and SHOULD NOT be accessed directly.
*
* @internal