XRL  latest
Simple XML-RPC Library (both client and server)
AbstractCollection.php
1 <?php
2 /*
3  * This file is part of XRL, a simple XML-RPC Library for PHP.
4  *
5  * Copyright (c) 2012, XRL Team. All rights reserved.
6  * XRL is licensed under the 3-clause BSD License.
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11 
12 namespace fpoirotte\XRL\Types;
13 
21 abstract class AbstractCollection extends \fpoirotte\XRL\Types\AbstractType implements
23  \Iterator,
25 {
27  protected $index = 0;
28 
35  public function __toString()
36  {
37  return print_r($this->get(), true);
38  }
39 
46  public function count()
47  {
48  return count($this->value);
49  }
50 
61  public function & offsetGet($offset)
62  {
63  return $this->value[$offset];
64  }
65 
78  public function offsetExists($offset)
79  {
80  return array_key_exists($offset, $this->value);
81  }
82 
90  public function current()
91  {
92  return $this->value[$this->key()];
93  }
94 
101  public function next()
102  {
103  $this->index++;
104  }
105 
112  public function rewind()
113  {
114  $this->index = 0;
115  }
116 
125  public function valid()
126  {
127  return ($this->index >= 0 && $this->index < count($this->value));
128  }
129 }
Interface to provide accessing objects as arrays.
Definition: ArrayAccess.php:10
$index
Current index in the collection.
Interface for external iterators or objects that can be iterated themselves internally.
Definition: Iterator.php:11
A class representing an abstract XML-RPC type.
An abstract XML-RPC type representing a collection of values.
Classes implementing Countable can be used with the count() function.
Definition: Countable.php:11