This sets the amount only if it is null.

This is to prevent an accidental overwriting of it.

@param Money|MoneyInterface $amount

@throws \InvalidArgumentException If the amount is not an integer

@return StripeLocalCharge
973965
public function setAmount(MoneyInterface $amount): self
    {
        if (null === $this->amount) {
            $this->amount = $amount;
        }

        return $this;
    }
37276
private function createMoney(int $amount = 0): ?Money
    {
        if (!$this->currency) {
            return null;
        }

        return DandomainFoundation\createMoney($this->currency->getIsoCodeAlpha(), $amount);
    }
1280423
public function setAmount($amount)
    {
        if ($amount instanceof DBMoney) {
            $this->setField('Money', $amount);
        } elseif ($this->Status == 'Created' && is_numeric($amount)) {
            $this->MoneyAmount = $amount;
        }
        return $this;
    }
600027
public function setAmount($amount)
    {
        $effects = $this->unserializeEffects($this->getSerializedEffects());
        $effects['amount'] = \floatval($amount);
        $this->setEffects($effects);

        return $this;
    }
191452
public function sale($amount = null)
    {
        $builder = new HpsGiftCardServiceSaleBuilder($this);
        return $builder
            ->withAmount($amount)
            ->withCurrency('usd');
    }
1196455
public function exchange(Money $money, $roundingMode = Money::ROUND_HALF_UP)
    {
        if ($money->getCurrency() != $this->getFromCurrency()) {
            throw new Exception\InvalidArgumentException('The Money has the wrong currency');
        }

        return $money->exchange($this->getToCurrency(), $this->getExchangeRate(), $roundingMode);
    }
203573
public function desaturate($amount)
    {
        if ($amount < 0 || $amount > 100) {
            throw new InvalidArgumentException('The given amount must be between 0 and 100');
        }
        $amount /= 100;
        $this->saturation -= $this->saturation * $amount;

        return $this;
    }
655746
public function validateMoney(MoneyInterface $money)
    {
        try {
            $this->numberValidator->validateNumber($money->getAmount());
        } catch (InvalidNumberException $exception) {
            throw new InvalidAmountException(
                'Invalid amount for money specified: ' . $money->getAmount(),
                0,
                $exception
            );
        }

        if (!($this->math->isZero($money->getAmount()) && $money->getCurrency() === null)) {
            if (!is_string($money->getCurrency())) {
                throw new InvalidCurrencyException('Specified currency is not string');
            } elseif (!in_array($money->getCurrency(), $this->informationProvider->getSupportedCurrencies())) {
                throw new InvalidCurrencyException('Invalid currency specified: ' . $money->getCurrency());
            }
        }
    }
114405
public function setAmount($amount)
    {
        $this->amount = $amount;

        // If we haven't set the amount_due yet, let's do it now
        if (null === $this->getAmountDue()) {
            $this->setAmountDue($amount);
        }
    }
833158
public function setAmount($amount)
    {
        if (!is_int($amount)) {
            throw new InvalidArgumentException("Integer expected. Amount is always in cents");
        }
        if ($amount <= 0) {
            throw new InvalidArgumentException("Amount must be a positive number");
        }
        $this->parameters['amount'] = $amount;
    }
591884
public function validateMoney(MoneyInterface $money)
    {
        $this->baseValidator->validateMoney($money);

        $precision = $this->informationProvider->getDefaultPrecision($money->getCurrency());
        if (!$this->math->isEqual($money->getAmount(), $this->math->round($money->getAmount(), $precision))) {
            throw new InvalidAmountException(sprintf(
                'Too specific amount (%s) for currency (%s) specified',
                $money->getAmount(),
                $money->getCurrency()
            ));
        }
    }
273428
public function setPrice(MoneyInterface $amount)
    {
        $this->priceAmount = $amount->getAmount();
        $this->priceCurrency = $amount->getCurrency();

        return $this;
    }
635643
public function invoiceFor($description, $amount, array $options = [])
    {
        if (!$this->stripe_id) {
            throw new InvalidArgumentException('User is not a customer. See the createAsStripeCustomer method.');
        }

        $options = array_merge([
            'customer' => $this->stripe_id,
            'amount' => $amount,
            'currency' => $this->preferredCurrency(),
            'description' => $description,
        ], $options);

        StripeInvoiceItem::create(
            $options, ['api_key' => $this->getStripeKey()]
        );

        return $this->invoice();
    }
1221546
public function setAmount(float $amount): self
    {
        $this->amount = (int) ($amount * self::FACTOR_AMOUNT);
        return $this;
    }
893711
public RoundedMoney with(Number amount) {
        checkNumber(amount);
        return new RoundedMoney(MoneyUtils.getBigDecimal(amount), currency, rounding);
    }
1198569
public function charge($amount, array $options = []): Charge
    {
        $options = array_merge([
            'currency' => $this->preferredCurrency(),
        ], $options);

        $options['amount'] = $amount;

        if (!array_key_exists('source', $options) && $this->stripe_id) {
            $options['customer'] = $this->stripe_id;
        }

        if (!array_key_exists('source', $options) && !array_key_exists('customer', $options)) {
            throw new InvalidArgumentException('No payment source provided.');
        }

        return Charge::create($options, ['api_key' => $this->getStripeKey()]);
    }
1224415
public function reduce(BankInterface $bank = null, $toCurrency = null)
    {
        if (null === $bank) {
            $bank = static::getBank();
        }

        if (!$bank instanceof MultiCurrencyBankInterface) {
            throw new \InvalidArgumentException('The supplied bank must implement MultiCurrencyBankInterface');
        }

        $rounder = $bank->getRounder();
        $amount = bcadd(
            $this->getAugend()->reduce($bank, $toCurrency)->getAmount(),
            $this->getAddend()->reduce($bank, $toCurrency)->getAmount(),
            $rounder->getPrecision() + 1
        );

        $amount = $rounder->round($amount, $toCurrency);

        return $bank->createMoney($amount, $toCurrency);
    }