<commit_before><?php
/**
 * spiral
 *
 * @author    Wolfy-J
 */
namespace Spiral\Pagination;

use Psr\Http\Message\ServerRequestInterface;
use Spiral\Core\Container\SingletonInterface;
use Spiral\Core\ContainerInterface;
use Spiral\Core\Exceptions\ScopeException;

/**
 * Paginators factory binded to active request scope in order to select page number.
 */
class PaginationManager implements SingletonInterface, PaginatorsInterface
{
    /**
     * @var ContainerInterface
     */
    private $container;

    /**
     * @param ContainerInterface $container
     */
    public function __construct(ContainerInterface $container)
    {
        $this->container = $container;
    }

    /**
     * {@inheritdoc}
     *
     * @throws ScopeException When no request are available.
     */
    public function createPaginator(string $parameter, int $limit = 25): PaginatorInterface
    {
        if (!$this->container->has(ServerRequestInterface::class)) {
            throw new ScopeException("Unable to create paginator, no request scope found");
        }

        /**
         * @var ServerRequestInterface $request
         */
        $request = $this->container->get(ServerRequestInterface::class);

        //Getting page number
        $page = 0;
        if (!empty($request->getQueryParams()[$parameter]) && is_scalar($request->getQueryParams()[$parameter])) {
            $page = (int)$request->getQueryParams()[$parameter];
        }

        //Initiating paginator
        return $this->container->make(Paginator::class, compact('limit'))->withPage($page);
    }
}<commit_msg>pagination is now following http scope<commit_after><?php
/**
 * spiral
 *
 * @author    Wolfy-J
 */
namespace Spiral\Pagination;

use Psr\Http\Message\ServerRequestInterface;
use Spiral\Core\Container\SingletonInterface;
use Spiral\Core\ContainerInterface;
use Spiral\Core\Exceptions\ScopeException;

/**
 * Paginators factory binded to active request scope in order to select page number.
 */
class PaginationManager implements SingletonInterface, PaginatorsInterface
{
    /**
     * @var ContainerInterface
     */
    private $container;

    /**
     * @param ContainerInterface $container
     */
    public function __construct(ContainerInterface $container)
    {
        $this->container = $container;
    }

    /**
     * {@inheritdoc}
     *
     * @throws ScopeException When no request are available.
     */
    public function createPaginator(string $parameter, int $limit = 25): PaginatorInterface
    {
        if (!$this->container->has(ServerRequestInterface::class)) {
            throw new ScopeException("Unable to create paginator, no request scope found");
        }

        /**
         * @var array $query
         */
        $query = $this->container->get(ServerRequestInterface::class)->getQueryParams();

        //Getting page number
        $page = 0;
        if (!empty($query[$parameter]) && is_scalar($query[$parameter])) {
            $page = (int)$query[$parameter];
        }

        //Initiating paginator
        return $this->container->make(Paginator::class, compact('limit'))->withPage($page);
    }
}
{'fraction_non_alphanumeric': 0.12452107279693486, 'fraction_numerical': 0.0019157088122605363, 'mean_word_length': 2.91625, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2758748', 'n_tokens_mistral': 852, 'n_tokens_neox': 830, 'n_words': 191}