Skip to content
Snippets Groups Projects
Select Git revision
  • 219913250eeb9ed8d3b0c9b10695367ac03ffc0d
  • main default protected
  • v0.2.1
  • v0.2.0
  • v0.1.2
  • v0.1.0
  • v0.1.1
7 results

Configuration.php

Blame
  • Pagination.php 747 B
    <?php
    
    declare(strict_types=1);
    
    namespace Dbp\Relay\CoreBundle\Pagination;
    
    class Pagination
    {
        private const CURRENT_PAGE_NUMBER_DEFAULT = 1;
        public const MAX_NUM_ITEMS_PER_PAGE_DEFAULT = 30;
    
        private const CURRENT_PAGE_NUMBER_PARAMETER_NAME = 'page';
        private const MAX_NUM_ITEMS_PER_PAGE_PARAMETER_NAME = 'perPage';
    
        public static function getCurrentPageNumber(array $options): int
        {
            return max(1, intval($options[self::CURRENT_PAGE_NUMBER_PARAMETER_NAME] ?? self::CURRENT_PAGE_NUMBER_DEFAULT));
        }
    
        public static function getMaxNumItemsPerPage(array $options): int
        {
            return max(1, intval($options[self::MAX_NUM_ITEMS_PER_PAGE_PARAMETER_NAME] ?? self::MAX_NUM_ITEMS_PER_PAGE_DEFAULT));
        }
    }