number = BigInt::create($number); } abstract public static function create(BigInteger|int|string $number): self; /** * Get the number as a base 10. * * @return string Integer as a string */ public function number(): string { return $this->number->base10(); } public function getValue(): BigInteger { return $this->number->getValue(); } /** * Get the number as an integer type. */ public function intNumber(): int { return $this->number->toInt(); } protected function encodedAsDER(): string { return $this->number->signedOctets(); } /** * Test that number is valid for this context. */ private static function validateNumber(mixed $num): bool { if (is_int($num)) { return true; } if (is_string($num) && preg_match('/-?\d+/', $num) === 1) { return true; } if ($num instanceof BigInteger) { return true; } return false; } }