For AI agents: a documentation index is available at https://www.mongodb.com/pt-br/docs/llms.txt — markdown versions of all pages are available by appending .md to any URL path.
Docs Menu

MongoDB\Model\CollectionInfo::getCappedMax()

Deprecated since version 1.9. :

MongoDB\Model\CollectionInfo::getCappedMax()

Return the document limit for the capped collection. This correlates with the max option for MongoDB\Database::createCollection().

function getCappedMax(): integer|null

The document limit for the capped collection. If the collection is not capped, null will be returned.

This method is deprecated in favor of using MongoDB\Model\CollectionInfo::getOptions() and accessing the max key.

<?php
$db = (new MongoDB\Client)->test;
// Creates a capped collection with a document limit of 100
$db->createCollection(
'myCappedCollection',
['capped' => true, 'size' => 1048576, 'max' => 100]
);
// Retrieves the document limit for the capped collection
foreach ($db->listCollections(['filter' => ['name' => 'myCappedCollection']]) as $info) {
var_dump($info->getCappedMax());
}

The output would then resemble:

int(100)