@param Amount | FeeContract $amount

@return Amount
@throws \Throwable
338386
public function subtract($amount)
    {
        if ($amount instanceof FeeContract) {
            return $amount->subtract($this)->convertTo($this->currency());
        }

        throw_unless($amount instanceof Amount, BadMethodCallException::class);

        return new static(
            $this->amount - $amount->convertTo($this->currency())->amount,
            $this->currency()
        );
    }
248450
public function createFromValues($amount, $taxAmount)
    {
        return new TaxedPrice(
            $this->moneyFactory->createFromValue($amount),
            $this->moneyFactory->createFromValue($taxAmount)
        );
    }
249609
public function authorize($amount = null)
    {
        return (new AuthorizationBuilder(TransactionType::AUTH, $this))
                        ->withAmount($amount)
                        ->withOneTimePayment(true);
    }
1271351
public static function adsToClicks($amount): int
    {
        $amountAsString = (string)$amount;
        if (strpos($amountAsString, '.') !== false) {
            $ar = explode('.', $amountAsString);
            $ar[1] = str_pad($ar[1], 11, '0');
            $amountAsString = implode($ar);
        } else {
            $amountAsString = $amountAsString . '00000000000';
        }
        return (int)$amountAsString;
    }
383204
public function dec(string $key, int $amount=1): int
  {
    $success = false;
    $value = \apcu_dec( $key, $amount, $success);

    return ( $success ? $value : false );
  }
988268
public function fee($fee = null)
    {
        $amount = $fee ?: $this->getAttribute("fee");
        if (!$amount)
            $amount = (int) Fee::calculateForTransaction($this);

        return new Fee(["amount" => $amount]);
    }
304193
public function output($amount = 1)
    {
        $collection = [];

        for ($i = 1; $i <= $amount; $i++) {
            $random = $this->generate();

            while (!$this->validate($collection, $random)) {
                $random = $this->generate();
            }

            array_push($collection, $random);
        }

        return $collection;
    }
51775
protected function convertAmount($amount, $convert = false)
    {
        if (!$convert) {
            return $amount;
        }

        return $amount * $this->currency->getSubunit();
    }
1048463
public function chunk($amount, callable $fn = null)
    {
        $this->prepare();

        $chunk_value = array_chunk($this->_map, $amount);
        $chunks = [];

        if (!is_null($fn) && is_callable($fn)) {
            foreach ($chunk_value as $chunk) {
                $return = $fn($chunk);
                if (!is_null($return)) {
                    $chunks[] = $return;
                }
            }
            return count($chunks) > 0 ? $chunks : null;
        }

        return $chunk_value;
    }
1306274
final public function limit(int $amount = null)
    {
        $this->limitAmount = $amount === null ? null : $amount;

        return $this;
    }
1073538
public function charge($amount = null)
    {
        return (new AuthorizationBuilder(TransactionType::SALE, $this))
                        ->withAmount($amount)
                        ->withOneTimePayment(true);
    }
1151945
public function setAmount($amount)
    {
        if ($amount === null) {
            $this->amount = 0;
            return $this;
        }
        
        if (!is_int($amount)) {
            throw new InvalidArgumentException(sprintf(
                'Amount must be an integer, "%s" given',
                is_object($amount) ? get_class($amount) : gettype($amount)
            ));
        }
        
        // Overflow check is not necessary because we have an integer
        $this->amount = $amount;
        return $this;
    }
1049819
public function capture(Varien_Object $payment, $amount)
    {
        parent::capture($payment, $amount);
        $payment->setStatus(self::STATUS_APPROVED)
            ->setTransactionId($this->getTransactionId())
            ->setIsTransactionClosed(0);
        $order = $payment->getOrder();
        $currency = $order->getOrderCurrencyCode();

        if ($payment->hasCurrentInvoice() && $currency != $order->getBaseCurrencyCode()) {
            $invoice = $payment->getCurrentInvoice();
            $amount = $invoice->getGrandTotal();
        }

        // do capture request to adyen
        $order = $payment->getOrder();
        $pspReference = Mage::getModel('adyen/event')->getOriginalPspReference($order->getIncrementId());
        $order->getPayment()->getMethodInstance()->sendCaptureRequest($payment, $amount, $pspReference);

        return $this;
    }
499235
public static function toCents($amount)
    {
        /*
         * There's probably a better way, but this is what i could come up with
         * to avoid rounding errors
         * todo: search for a better way
         */

        if (!is_float($amount)) {
            $type = gettype($amount);

            throw new \UnexpectedValueException("Needs a float! not $type");
        }

        //handle locales
        $locale = localeconv();

        $amount = str_replace($locale['mon_thousands_sep'], '', $amount);
        $amount = str_replace($locale['mon_decimal_point'], '.', $amount);
        $amount = str_replace($locale['decimal_point'], '.', $amount);

        $parts = explode('.', "$amount");

        // handle the case where $amount has a .0 fraction part
        if (count($parts) == 1) {
            $parts[] = '00';
        }

        list($whole, $fraction) = $parts;

        /*
         * since the documentation only mentions decimals with a precision of two
         * and doesn't specify any rounding method i'm truncating the number
         *
         * the str_pad is to handle the case where $amount is, for example, 6.9
         */
        $fraction = str_pad(substr($fraction, 0, 2), 2, '0');

        $whole = (int) $whole * 100;
        $fraction = (int) $fraction;

        return $whole + $fraction;
    }
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()]);
    }
1257108
public function setAmount($amount)
    {
      if(!is_int($amount) || $amount < 0)
        throw new InvalidArgumentException(__METHOD__ . '; Invalid amount, must be a positive integer');

      $this->amount = $amount;
    }
1337320
public function validateMax($amount)
    {
        $this->validator_attributes[] = 'data-parsley-max="' . (float)$amount . '"';

        $this->validator_checks['max'] = (float)$amount;

        return $this;
    }