What are the advantages and disadvantages of using classes for pagination in PHP, as discussed in the thread?

Using classes for pagination in PHP can help organize and encapsulate the pagination logic, making it easier to maintain and reuse. However, it may introduce additional complexity for simple pagination needs and require more code to set up compared to a procedural approach.

class Pagination {
    private $totalItems;
    private $itemsPerPage;
    
    public function __construct($totalItems, $itemsPerPage) {
        $this->totalItems = $totalItems;
        $this->itemsPerPage = $itemsPerPage;
    }

    public function getTotalPages() {
        return ceil($this->totalItems / $this->itemsPerPage);
    }

    public function getItemsForPage($page) {
        // Calculate offset and fetch items for the given page
    }
}

// Example usage
$pagination = new Pagination(100, 10);
$totalPages = $pagination->getTotalPages();
$items = $pagination->getItemsForPage(2);