Skip to content
Snippets Groups Projects
Pagination.php 577 B
Newer Older
Pavel's avatar
Pavel committed
<?php

namespace IQDEV\ElasticSearch\Search;

use IQDEV\ElasticSearch\Esable;

class Pagination implements Esable
{
Pavel's avatar
Pavel committed
    private ?int $size;
    private ?int $from;
Pavel's avatar
Pavel committed

    public function __construct(?int $size = null, ?int $from = null)
    {
        $this->size = $size;
        $this->from = $from;
    }

    public function es(): array
    {
        $pagination = [];

        if ($this->from) {
            $pagination['from'] = $this->from;
        }

        if ($this->size) {
            $pagination['size'] = $this->size;
        }

        return $pagination;
    }
}