/var/www/myprog.com.ua/telegram/webhooks/vendor/telegram-bot/api/src/Collection
Edit: /var/www/myprog.com.ua/telegram/webhooks/vendor/telegram-bot/api/src/Collection/Collection.php (2322B)
maxCount > 0 && $this->count() + 1 >= $this->maxCount) {
throw new ReachedMaxSizeException("Maximum collection items count reached. Max size: {$this->maxCount}");
}
if ($key == null) {
$this->items[] = $item;
} else {
if (isset($this->items[$key])) {
throw new KeyHasUseException("Key $key already in use.");
}
$this->items[$key] = $item;
}
}
/**
* @param $key
* @throws KeyInvalidException
* @return void
*/
public function deleteItem($key)
{
$this->checkItemKey($key);
unset($this->items[$key]);
}
/**
* @param $key
* @return InputMedia
* @return CollectionItemInterface
* @throws KeyInvalidException
*/
public function getItem($key)
{
$this->checkItemKey($key);
return $this->items[$key];
}
/**
* @return int
*/
public function count()
{
return count($this->items);
}
/**
* @param bool $inner
* @return array|string
*/
public function toJson($inner = false)
{
$output = [];
foreach ($this->items as $item) {
$output[] = $item->toJson(true);
}
return $inner === false ? json_encode($output) : $output;
}
/**
* @param int $maxCount
* @return void
*/
public function setMaxCount($maxCount)
{
$this->maxCount = $maxCount;
}
/**
* @param $key
* @throws KeyInvalidException
*/
private function checkItemKey($key)
{
if (!isset($this->items[$key])) {
throw new KeyInvalidException("Invalid key $key.");
}
}
}