public function setPaginator($class, $options = [])
    {
        $interfaces = class_implements($class);

        if (in_array('Illuminate\Contracts\Pagination\LengthAwarePaginator', $interfaces)) {
            $paginator = new $class($this->items, $this->total, $this->perPage, $this->currentPage, $options);
        } elseif (in_array('Illuminate\Contracts\Pagination\Paginator', $interfaces)) {
            $paginator = new $class($this->items, $this->perPage, $this->currentPage, $options);
            $paginator->hasMorePagesWhen($this->hasMore);
        } else {
            throw new \InvalidArgumentException('Cannot use the given paginator.');
        }

        $this->paginator = $paginator;
    }