b6714acf364937ffe4187f0ec09c6a8f0f2fe5fa
[ssproject1617.git] / testcms-final-anon / system / classes / items.php
1 <?php defined('IN_CMS') or die('No direct access allowed.');
2
3 class Items implements Iterator {
4
5 private $position = 0;
6 private $items = array();
7
8 public function __construct($array) {
9 $this->position = 0;
10 $this->items = $array;
11 }
12
13 public function rewind() {
14 $this->position = 0;
15 }
16
17 public function current() {
18 return $this->items[$this->position];
19 }
20
21 public function key() {
22 return $this->position;
23 }
24
25 public function next() {
26 ++$this->position;
27 }
28
29 public function valid() {
30 return isset($this->items[$this->position]);
31 }
32
33 public function length() {
34 return count($this->items);
35 }
36
37 public function first() {
38 return isset($this->items[0]) ? $this->items[0] : false;
39 }
40
41 public function last() {
42 $index = count($this->items) - 1;
43 return isset($this->items[$index]) ? $this->items[$index] : false;
44 }
45
46 }