5 use Friendica\Database\Database;
6 use Friendica\Database\DBA;
7 use Psr\Log\LoggerInterface;
10 * The Collection classes inheriting from this abstract class are meant to represent a list of database record.
11 * The associated model class has to be provided in the child classes.
13 * Collections can be used with foreach(), accessed like an array and counted.
15 abstract class BaseCollection extends \ArrayIterator
18 * This property is used with paginated results to hold the total number of items satisfying the paginated request.
21 protected $totalCount = 0;
24 * @param BaseModel[] $models
25 * @param int|null $totalCount
27 public function __construct(array $models = [], int $totalCount = null)
29 parent::__construct($models);
31 $this->models = $models;
32 $this->totalCount = $totalCount ?? count($models);
38 public function getTotalCount()
40 return $this->totalCount;