<commit_before><?php

namespace Knp\Component\Pager\Pagination;

use Countable, Iterator;

abstract class AbstractPagination implements PaginationInterface, Countable, Iterator
{
    protected $currentPageNumber;
    protected $numItemsPerPage;
    protected $items = array();
    protected $totalCount;
    protected $alias;

    /**
     * {@inheritDoc}
     */
    public function rewind() {
        reset($this->items);
    }

    /**
     * {@inheritDoc}
     */
    public function current() {
        return current($this->items);
    }

    /**
     * {@inheritDoc}
     */
    public function key() {
        return key($this->items);
    }

    /**
     * {@inheritDoc}
     */
    public function next() {
        next($this->items);
    }

    /**
     * {@inheritDoc}
     */
    public function valid() {
        return key($this->items) !== null;
    }

    /**
     * {@inheritDoc}
     */
    public function count()
    {
        return count($this->items);
    }

    /**
     * {@inheritDoc}
     */
    public function setCurrentPageNumber($pageNumber)
    {
        $this->currentPageNumber = $pageNumber;
    }

    /**
     * Get currently used page number
     *
     * @return integer
     */
    public function getCurrentPageNumber()
    {
        return $this->currentPageNumber;
    }

    /**
     * {@inheritDoc}
     */
    public function setItemNumberPerPage($numItemsPerPage)
    {
        $this->numItemsPerPage = $numItemsPerPage;
    }

    /**
     * Get number of items per page
     *
     * @return integer
     */
    public function getItemNumberPerPage()
    {
        return $this->numItemsPerPage;
    }

    /**
     * {@inheritDoc}
     */
    public function setTotalItemCount($numTotal)
    {
        $this->totalCount = $numTotal;
    }

    /**
     * Get total item number available
     *
     * @return integer
     */
    public function getTotalItemCount()
    {
        return $this->totalCount;
    }

    /**
     * {@inheritDoc}
     */
    public function setAlias($paginationAlias)
    {
        $this->alias = $paginationAlias;
    }

    /**
     * Get pagination alias
     *
     * @return string
     */
    public function getAlias()
    {
        return $this->alias;
    }

    /**
     * {@inheritDoc}
     */
    public function setItems($items)
    {
        if (!is_array($items) && !$items instanceof \Traversable) {
            throw new \UnexpectedValueException("Items must be an array type");
        }
        $this->items = $items;
    }

    /**
     * Get current items
     *
     * @return array
     */
    public function getItems()
    {
        return $this->items;
    }
}<commit_msg>added ArrayAccess to AbstractPagination<commit_after><?php

namespace Knp\Component\Pager\Pagination;

use Countable, Iterator, ArrayAccess;

abstract class AbstractPagination implements PaginationInterface, Countable, Iterator, ArrayAccess
{
    protected $currentPageNumber;
    protected $numItemsPerPage;
    protected $items = array();
    protected $totalCount;
    protected $alias;

    /**
     * {@inheritDoc}
     */
    public function rewind() {
        reset($this->items);
    }

    /**
     * {@inheritDoc}
     */
    public function current() {
        return current($this->items);
    }

    /**
     * {@inheritDoc}
     */
    public function key() {
        return key($this->items);
    }

    /**
     * {@inheritDoc}
     */
    public function next() {
        next($this->items);
    }

    /**
     * {@inheritDoc}
     */
    public function valid() {
        return key($this->items) !== null;
    }

    /**
     * {@inheritDoc}
     */
    public function count()
    {
        return count($this->items);
    }

    /**
     * {@inheritDoc}
     */
    public function setCurrentPageNumber($pageNumber)
    {
        $this->currentPageNumber = $pageNumber;
    }

    /**
     * Get currently used page number
     *
     * @return integer
     */
    public function getCurrentPageNumber()
    {
        return $this->currentPageNumber;
    }

    /**
     * {@inheritDoc}
     */
    public function setItemNumberPerPage($numItemsPerPage)
    {
        $this->numItemsPerPage = $numItemsPerPage;
    }

    /**
     * Get number of items per page
     *
     * @return integer
     */
    public function getItemNumberPerPage()
    {
        return $this->numItemsPerPage;
    }

    /**
     * {@inheritDoc}
     */
    public function setTotalItemCount($numTotal)
    {
        $this->totalCount = $numTotal;
    }

    /**
     * Get total item number available
     *
     * @return integer
     */
    public function getTotalItemCount()
    {
        return $this->totalCount;
    }

    /**
     * {@inheritDoc}
     */
    public function setAlias($paginationAlias)
    {
        $this->alias = $paginationAlias;
    }

    /**
     * Get pagination alias
     *
     * @return string
     */
    public function getAlias()
    {
        return $this->alias;
    }

    /**
     * {@inheritDoc}
     */
    public function setItems($items)
    {
        if (!is_array($items) && !$items instanceof \Traversable) {
            throw new \UnexpectedValueException("Items must be an array type");
        }
        $this->items = $items;
    }

    /**
     * Get current items
     *
     * @return array
     */
    public function getItems()
    {
        return $this->items;
    }
    
    public function offsetExists($offset) 
    {
        return array_key_exists($offset, $this->items);
    }
    
    public function offsetGet($offset) 
    {
        return $this->items[$offset];
    }
    
    public function offsetSet($offset, $value) 
    {
        $this->items[$offset] = $value;
    }
    
    public function offsetUnset($offset) 
    {
        unset($this->items[$offset]);
    }
}
{'fraction_non_alphanumeric': 0.1297473792747895, 'fraction_numerical': 0.0, 'mean_word_length': 1.8362573099415205, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 39, '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': '3629890', 'n_tokens_mistral': 1722, 'n_tokens_neox': 1690, 'n_words': 344}