Could we add($amount, $key) without exceeding the quota?

@param int $amount
@param int|string|array $key

@return boolean
483058
public function canAdd($amount, $key = '')
    {
        return $this->getCount($key) + $amount <= $this->getTarget($key, 0);
    }
1306274
final public function limit(int $amount = null)
    {
        $this->limitAmount = $amount === null ? null : $amount;

        return $this;
    }
600027
public function setAmount($amount)
    {
        $effects = $this->unserializeEffects($this->getSerializedEffects());
        $effects['amount'] = \floatval($amount);
        $this->setEffects($effects);

        return $this;
    }
1167529
public function random($amount = 1)
    {
        if ($amount > ($count = $this->count())) {

            throw new InvalidArgumentException("You requested {$amount} items, but there are only {$count} items in the collection.");
        }

        $keys = array_rand($this->items, $amount);

        if (count(func_get_args()) == 0) {

            return $this->items[ $keys ];
        }

        $keys = !is_array($keys) ? [$keys] : $keys;

        return new static(array_intersect_key($this->items, array_flip($keys)));
    }
322198
public function skip(int $amount)
    {
        $this->items = array_slice($this->items, $amount);

        return $this;
    }
1125014
public function writeOff($amount,$userId)
    {
        if (!$this->canPay($amount, $userId)) {
            return false;

        }

        return $this->repository->create([
            'user_id' => $userId,
            'value' => $amount,
            'accepted' => 1,
            'hash' => uniqid('transaction_', true),
            'type' => BalanceTransaction::CONST_TYPE_PAYMENT,
        ]);

    }
251024
public function setAmount($amount)
    {
        $amount = (int) (string) $amount;

        if (!Icepay_Parameter_Validation::amount($amount))
            throw new Exception('Amount not valid');
        $this->data->ic_amount = $amount;
        return $this;
    }
732390
public function setSubmitted($key, $data)
    {
        if (isset($key)) {
            gplcart_array_set($this->submitted, $key, $data);
            return $this->submitted;
        }

        return $this->submitted = (array) $data;
    }
891192
protected function incrementOrDecrement($column, $amount, $extra, $method)
    {
        $query = $this->newQuery();

        if (!$this->exists) {
            return $query->{$method}($column, $amount, $extra);
        }

        $this->incrementOrDecrementAttributeValue($column, $amount, $method);

        return $query->where(
            $this->getKeyName(),
            $this->getKey()
        )->{$method}($column, $amount, $extra);
    }
1016845
protected function incrementOrDecrementAttributeValue($column, $amount, $extra, $method)
    {
        $this->{$column} = $this->{$column} + ($method === 'increment' ? $amount : $amount * -1);

        $this->forceFill($extra);

        $this->syncOriginalAttribute($column);
    }
1121076
public static function add($key = null, $data = [])
    {
        // If no key is given
        if (is_null($key)) {
            // Set key to file and line
            $key = Debugger::getCalledFrom(2);
        }

        // If key is allready in use
        if (isset(self::$collection[$key])) {
            // Get original item
            $item = self::$collection[$key];

            // Set new item count
            $itemCount = (isset($item['count']) ? ($item['count'] + 1) : 2);

            // Set correct key for the original item
            if (strpos($item['key'], '#') === false) {
                self::$collection[$key] = array_merge($item, [
                    'key'   => $key . ' #1',
                    'count' => $itemCount,
                ]);
            } else {
                self::$collection[$key] = array_merge($item, [
                    'count' => $itemCount,
                ]);
            }

            // Set new key
            $key = $key . ' #' . $itemCount;
        }

        // Make sure various options are set
        if (!isset($data['key'])) {
            $data['key'] = $key;
        }
        if (!isset($data['parent'])) {
            $data['parent'] = self::$currentItem;
        }
        if (!isset($data['level'])) {
            $data['level'] = 0;
            if (isset($data['parent']) && isset(self::$collection[$data['parent']])) {
                $data['level'] = (self::$collection[$data['parent']]['level'] + 1);
            }
        }

        // Add item to collection
        self::$collection[$key] = $data;

        return $key;
    }
307242
public function incrementRateLimitCallCount(int $amount = 1)
    {

        cache()->set($this->getRateLimitKey(), $amount, carbon('now')->addMinute(1));
    }
1342835
public void incrementFeatureByIndex(double amount, int... key) {
    if (isDense) {
      statistics.incrementEntry(amount, key);
    } else {
      Tensor increment = SparseTensor.singleElement(getTensorDimensions(), getTensorSizes(),
          key, amount);
      statisticsTensor = statisticsTensor.elementwiseAddition(increment);
    }
  }
1358801
public function incrementEsiRateLimit(int $amount = 1)
    {

        if ($this->getRateLimitKeyTtl() > 3) {

            cache()->increment($this->ratelimit_key, $amount);

        } else {

            cache()->set($this->ratelimit_key, $amount, carbon('now')
                ->addMinutes($this->ratelimit_duration));
        }
    }
2965
public boolean put(final int key) {
		if (isFull()) { // full
			resizeArray();
		}
		int slot = findSlotByKey(key);
		if (slot >= 0) {
			if (log.isDebugEnabled()) {
				log.debug("key already exists: " + key);
			}
			return false; // key already exist
		}
		slot = ((-slot) - 1);
		return addSlot(slot, key);
	}
1163325
public function increment($column, $amount = 1, array $extra = [])
    {
        $result = $this->getBuilder()->increment($column, $amount, $extra);

        // Reset query builder
        $this->resetBuilder();

        return (int) $result;
    }
216247
final public function decrement($column, $amount = 1)
    {
        if (is_array($amount)) {
            $amount = array_map(function ($item) {
                return (0 - $item);
            }, $amount);
        } else {
            $amount = 0 - $amount;
        }
        return $this->stepField($column, $amount);
    }