6 * The Collection classes inheriting from this abstract class are meant to represent a list of database record.
7 * The associated model class has to be provided in the child classes.
9 * Collections can be used with foreach(), accessed like an array and counted.
11 abstract class BaseCollection extends \ArrayIterator
14 * This property is used with paginated results to hold the total number of items satisfying the paginated request.
17 protected $totalCount = 0;
20 * @param BaseModel[] $models
21 * @param int|null $totalCount
23 public function __construct(array $models = [], int $totalCount = null)
25 parent::__construct($models);
27 $this->models = $models;
28 $this->totalCount = $totalCount ?? count($models);
34 public function getTotalCount()
36 return $this->totalCount;