<?php
namespace SabaiApps\Framework\Model\Paginator;

use SabaiApps\Framework\Model\AbstractEntityRepository;

/**
 * AbstractPaginator class for paginating entities.
 * Provides common functionality for fetching and counting entities in pages.
 */
abstract class AbstractPaginator extends \SabaiApps\Framework\Paginator\AbstractPaginator {

	protected $_repository, $_sort, $_order;

	/**
	 * Constructor.
	 *
	 * @param AbstractEntityRepository $repository Entity repository.
	 * @param int                      $perpage Number of entities per page.
	 * @param string                   $sort Sorting field.
	 * @param string                   $order Sorting order (ASC/DESC).
	 * @param int                      $limit Maximum number of entities to fetch.
	 */
	public function __construct( AbstractEntityRepository $repository, $perpage, $sort, $order, $limit = 0 ) {
		parent::__construct( $perpage, $limit );
		$this->_repository = $repository;
		$this->_sort       = $sort;
		$this->_order      = $order;
	}

	/**
	 * Gets an empty collection of elements.
	 *
	 * @return mixed Empty collection.
	 */
	protected function _getEmptyElements() {
		return $this->_repository->createCollection();
	}
}
