1<?php 2/** 3 * Copyright since 2007 PrestaShop SA and Contributors 4 * PrestaShop is an International Registered Trademark & Property of PrestaShop SA 5 * 6 * NOTICE OF LICENSE 7 * 8 * This source file is subject to the Open Software License (OSL 3.0) 9 * that is bundled with this package in the file LICENSE.md. 10 * It is also available through the world-wide-web at this URL: 11 * https://opensource.org/licenses/OSL-3.0 12 * If you did not receive a copy of the license and are unable to 13 * obtain it through the world-wide-web, please send an email 14 * to license@prestashop.com so we can send you a copy immediately. 15 * 16 * DISCLAIMER 17 * 18 * Do not edit or add to this file if you wish to upgrade PrestaShop to newer 19 * versions in the future. If you wish to customize PrestaShop for your 20 * needs please refer to https://devdocs.prestashop.com/ for more information. 21 * 22 * @author PrestaShop SA and Contributors <contact@prestashop.com> 23 * @copyright Since 2007 PrestaShop SA and Contributors 24 * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) 25 */ 26 27namespace PrestaShop\PrestaShop\Core\Grid\Collection; 28 29use Countable; 30use Iterator; 31 32/** 33 * Class AbstractCollection is responsible for providing base collection implementation. 34 */ 35abstract class AbstractCollection implements Iterator, Countable 36{ 37 /** 38 * @var array 39 */ 40 protected $items = []; 41 42 /** 43 * {@inheritdoc} 44 */ 45 public function current() 46 { 47 return current($this->items); 48 } 49 50 /** 51 * @return mixed|false 52 */ 53 public function next() 54 { 55 return next($this->items); 56 } 57 58 /** 59 * {@inheritdoc} 60 */ 61 public function key() 62 { 63 return key($this->items); 64 } 65 66 /** 67 * {@inheritdoc} 68 */ 69 public function valid() 70 { 71 return false !== $this->current(); 72 } 73 74 /** 75 * {@inheritdoc} 76 */ 77 public function rewind() 78 { 79 reset($this->items); 80 } 81 82 /** 83 * {@inheritdoc} 84 */ 85 public function count() 86 { 87 return count($this->items); 88 } 89} 90