From 75160b12821f7f4299cce7f0b69c83c1502ae071 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20Luka=20=C5=A0ijanec?= Date: Mon, 27 May 2024 13:08:29 +0200 Subject: 2024-02-19 upstream --- vendor/fgrosse/phpasn1/lib/Utility/BigInteger.php | 390 +++++++++++----------- 1 file changed, 195 insertions(+), 195 deletions(-) (limited to 'vendor/fgrosse/phpasn1/lib/Utility/BigInteger.php') diff --git a/vendor/fgrosse/phpasn1/lib/Utility/BigInteger.php b/vendor/fgrosse/phpasn1/lib/Utility/BigInteger.php index 866162c..e1bb692 100644 --- a/vendor/fgrosse/phpasn1/lib/Utility/BigInteger.php +++ b/vendor/fgrosse/phpasn1/lib/Utility/BigInteger.php @@ -1,195 +1,195 @@ -_fromInteger($val); - } - else { - // convert to string, if not already one - $val = (string)$val; - - // validate string - if (!preg_match('/^-?[0-9]+$/', $val)) { - throw new \InvalidArgumentException('Expects a string representation of an integer.'); - } - $ret->_fromString($val); - } - - return $ret; - } - - /** - * BigInteger constructor. - * Prevent directly instantiating object, use BigInteger::create instead. - */ - protected function __construct() - { - - } - - /** - * Subclasses must provide clone functionality. - * @return BigInteger - */ - abstract public function __clone(); - - /** - * Assign the instance value from base 10 string. - * @param string $str - */ - abstract protected function _fromString($str); - - /** - * Assign the instance value from an integer type. - * @param int $integer - */ - abstract protected function _fromInteger($integer); - - /** - * Must provide string implementation that returns base 10 number. - * @return string - */ - abstract public function __toString(); - - /* INFORMATIONAL FUNCTIONS */ - - /** - * Return integer, if possible. Throws an exception if the number can not be represented as a native integer. - * @return int - * @throws \OverflowException - */ - abstract public function toInteger(); - - /** - * Is represented integer negative? - * @return bool - */ - abstract public function isNegative(); - - /** - * Compare the integer with $number, returns a negative integer if $this is less than number, returns 0 if $this is - * equal to number and returns a positive integer if $this is greater than number. - * @param BigInteger|string|int $number - * @return int - */ - abstract public function compare($number); - - /* MODIFY */ - - /** - * Add another integer $b and returns the result. - * @param BigInteger|string|int $b - * @return BigInteger - */ - abstract public function add($b); - - /** - * Subtract $b from $this and returns the result. - * @param BigInteger|string|int $b - * @return BigInteger - */ - abstract public function subtract($b); - - /** - * Multiply value. - * @param BigInteger|string|int $b - * @return BigInteger - */ - abstract public function multiply($b); - - /** - * The value $this modulus $b. - * @param BigInteger|string|int $b - * @return BigInteger - */ - abstract public function modulus($b); - - /** - * Raise $this to the power of $b and returns the result. - * @param BigInteger|string|int $b - * @return BigInteger - */ - abstract public function toPower($b); - - /** - * Shift the value to the right by a set number of bits and returns the result. - * @param int $bits - * @return BigInteger - */ - abstract public function shiftRight($bits = 8); - - /** - * Shift the value to the left by a set number of bits and returns the result. - * @param int $bits - * @return BigInteger - */ - abstract public function shiftLeft($bits = 8); - - /** - * Returns the absolute value. - * @return BigInteger - */ - abstract public function absoluteValue(); -} +_fromInteger($val); + } + else { + // convert to string, if not already one + $val = (string)$val; + + // validate string + if (!preg_match('/^-?[0-9]+$/', $val)) { + throw new \InvalidArgumentException('Expects a string representation of an integer.'); + } + $ret->_fromString($val); + } + + return $ret; + } + + /** + * BigInteger constructor. + * Prevent directly instantiating object, use BigInteger::create instead. + */ + protected function __construct() + { + + } + + /** + * Subclasses must provide clone functionality. + * @return BigInteger + */ + abstract public function __clone(); + + /** + * Assign the instance value from base 10 string. + * @param string $str + */ + abstract protected function _fromString($str); + + /** + * Assign the instance value from an integer type. + * @param int $integer + */ + abstract protected function _fromInteger($integer); + + /** + * Must provide string implementation that returns base 10 number. + * @return string + */ + abstract public function __toString(); + + /* INFORMATIONAL FUNCTIONS */ + + /** + * Return integer, if possible. Throws an exception if the number can not be represented as a native integer. + * @return int + * @throws \OverflowException + */ + abstract public function toInteger(); + + /** + * Is represented integer negative? + * @return bool + */ + abstract public function isNegative(); + + /** + * Compare the integer with $number, returns a negative integer if $this is less than number, returns 0 if $this is + * equal to number and returns a positive integer if $this is greater than number. + * @param BigInteger|string|int $number + * @return int + */ + abstract public function compare($number); + + /* MODIFY */ + + /** + * Add another integer $b and returns the result. + * @param BigInteger|string|int $b + * @return BigInteger + */ + abstract public function add($b); + + /** + * Subtract $b from $this and returns the result. + * @param BigInteger|string|int $b + * @return BigInteger + */ + abstract public function subtract($b); + + /** + * Multiply value. + * @param BigInteger|string|int $b + * @return BigInteger + */ + abstract public function multiply($b); + + /** + * The value $this modulus $b. + * @param BigInteger|string|int $b + * @return BigInteger + */ + abstract public function modulus($b); + + /** + * Raise $this to the power of $b and returns the result. + * @param BigInteger|string|int $b + * @return BigInteger + */ + abstract public function toPower($b); + + /** + * Shift the value to the right by a set number of bits and returns the result. + * @param int $bits + * @return BigInteger + */ + abstract public function shiftRight($bits = 8); + + /** + * Shift the value to the left by a set number of bits and returns the result. + * @param int $bits + * @return BigInteger + */ + abstract public function shiftLeft($bits = 8); + + /** + * Returns the absolute value. + * @return BigInteger + */ + abstract public function absoluteValue(); +} -- cgit v1.2.3