* Nils Adermann * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Packagist\WebBundle\Model; use Pagerfanta\Adapter\AdapterInterface; /** * @author Jordi Boggiano */ class RedisAdapter implements AdapterInterface { protected $model; protected $instance; protected $fetchMethod; protected $countMethod; public function __construct($model, $instance, $fetchMethod, $countMethod) { $this->model = $model; $this->instance = $instance; $this->fetchMethod = $fetchMethod; $this->countMethod = $countMethod; } /** * {@inheritDoc} */ public function getNbResults() { return $this->model->{$this->countMethod}($this->instance); } /** * {@inheritDoc} */ public function getSlice($offset, $length) { return $this->model->{$this->fetchMethod}($this->instance, $length, $offset); } }