File indexing completed on 2025-01-26 05:29:53
0001 <?php 0002 /** 0003 * Zend Framework 0004 * 0005 * LICENSE 0006 * 0007 * This source file is subject to the new BSD license that is bundled 0008 * with this package in the file LICENSE.txt. 0009 * It is also available through the world-wide-web at this URL: 0010 * http://framework.zend.com/license/new-bsd 0011 * If you did not receive a copy of the license and are unable to 0012 * obtain it through the world-wide-web, please send an email 0013 * to license@zend.com so we can send you a copy immediately. 0014 * 0015 * @category Zend 0016 * @package Zend_Service 0017 * @subpackage Ebay 0018 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0019 * @license http://framework.zend.com/license/new-bsd New BSD License 0020 * @version $Id: Abstract.php 20166 2010-01-09 19:00:17Z bkarwin $ 0021 */ 0022 0023 /** 0024 * @category Zend 0025 * @package Zend_Service 0026 * @subpackage Ebay 0027 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0028 * @license http://framework.zend.com/license/new-bsd New BSD License 0029 */ 0030 abstract class Zend_Service_Ebay_Finding_Set_Abstract implements SeekableIterator, Countable 0031 { 0032 /** 0033 * @var DOMNodeList 0034 */ 0035 protected $_nodes; 0036 0037 /** 0038 * @var integer 0039 */ 0040 protected $_key = 0; 0041 0042 /** 0043 * @param DOMNodeList $nodes 0044 * @return void 0045 */ 0046 public function __construct(DOMNodeList $nodes) 0047 { 0048 $this->_nodes = $nodes; 0049 $this->_init(); 0050 } 0051 0052 /** 0053 * Initialize object. 0054 * 0055 * Called from {@link __construct()} as final step of object initialization. 0056 * 0057 * @return void 0058 */ 0059 protected function _init() 0060 { 0061 } 0062 0063 /** 0064 * Implement SeekableIterator::seek() 0065 * 0066 * @param integer $key 0067 * @throws OutOfBoundsException When $key is not seekable 0068 * @return void 0069 */ 0070 public function seek($key) 0071 { 0072 if ($key < 0 || $key >= $this->count()) { 0073 $message = "Position '{$key}' is not seekable."; 0074 throw new OutOfBoundsException($message); 0075 } 0076 $this->_key = $key; 0077 } 0078 0079 /** 0080 * Implement Iterator::key() 0081 * 0082 * @return integer 0083 */ 0084 public function key() 0085 { 0086 return $this->_key; 0087 } 0088 0089 /** 0090 * Implement Iterator::next() 0091 * 0092 * @return void 0093 */ 0094 public function next() 0095 { 0096 $this->_key++; 0097 } 0098 0099 /** 0100 * Implement Iterator::rewind() 0101 * 0102 * @return void 0103 */ 0104 public function rewind() 0105 { 0106 $this->_key = 0; 0107 } 0108 0109 /** 0110 * Implement Iterator::valid() 0111 * 0112 * @return boolean 0113 */ 0114 public function valid() 0115 { 0116 return $this->_key >= 0 && $this->_key < $this->count(); 0117 } 0118 0119 /** 0120 * Implement Countable::current() 0121 * 0122 * @return integer 0123 */ 0124 public function count() 0125 { 0126 return $this->_nodes ? $this->_nodes->length : 0; 0127 } 0128 }