public function divide($divisor, ?RoundingMode $mode = null): Money
    {
        if ($mode === null) {
            $mode = RoundingMode::HALF_UP();
        }

        $this->guardOperand($divisor);

        if ($divisor === 0 || $divisor === 0.0) {
            throw new DomainException('Division by zero');
        }

        $amount = round($this->amount / $divisor, 0, $mode->value());
        $amount = $this->castToInteger($amount);

        return $this->withAmount($amount);
    }