/** * Safely set the current prime as a BigInteger. * * @param mixed $prime */ public function setPrime($prime) { if (!$prime instanceof BigInteger) { $prime = new BigInteger($prime); } if (!$prime->isPrime()) { throw new InvalidPrimeException($prime); } $this->prime = $prime; }