> For the complete documentation index, see [llms.txt](https://docs.sonsofphp.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sonsofphp.com/contracts/pager.md).

# Pager

The PHP Pager Contract is to support libraries that implement Pagination related components.

### Installation

```shell
composer require sonsofphp/pager-contract
```

### AdapterInterface

```php
<?php

namespace SonsOfPHP\Contract\Pager;

interface AdapterInterface extends \Countable
{
    /**
     * This will return part of the total results
     *
     * Offset is where the results to be returned will start, for example, if
     * offset is 0, it will start with the first record and return $length
     *
     * Offset should always be 0 or greater
     *
     * Length is how many results to return. For example, if length is 10, a
     * MAXIMUM of 10 results will be returned
     *
     * Length MUST always be a positive number that is 1 or greater OR be null
     *
     * If null is passed in as length, this should return ALL the results.
     *
     * If the total number of results is less than length, an exception must
     * not be thrown.
     *
     * @throws \InvalidArgumentException
     *   If offset or length is invalid, this expection will be thrown
     */
    public function getSlice(int $offset, ?int $length): iterable;
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sonsofphp.com/contracts/pager.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
