Completed
Pull Request — master (#6)
by
unknown
03:41 queued 01:28
created

_IteratorAdapter::rewind()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * functional: _IteratorAdapter.php
4
 */
5
6
namespace Tarsana\Functional;
7
8
/**
9
 * Provides an Iterator for a given associative SplObjectStorage collection which accesses the collection members like an ArrayIterator.
10
 * Class _IteratorAdapter
11
 * @package Tarsana\Functional
12
 * @internal
13
 */
14
class _IteratorAdapter implements \Iterator
15
{
16
	private $objectStorage;
17
18
	public function __construct(\SplObjectStorage $theObjectStorage)
19
	{
20
		$this->objectStorage = $theObjectStorage;
21
	}
22
23
	/**
24
	 * Return the current element
25
	 * @link http://php.net/manual/en/iterator.current.php
26
	 * @return mixed Can return any type.
27
	 * @since 5.0.0
28
	 */
29
	public function current()
30
	{
31
		return $this->objectStorage->getInfo();
32
	}
33
34
	/**
35
	 * Move forward to next element
36
	 * @link http://php.net/manual/en/iterator.next.php
37
	 * @return void Any returned value is ignored.
38
	 * @since 5.0.0
39
	 */
40
	public function next()
41
	{
42
		return $this->objectStorage->next();
43
	}
44
45
	/**
46
	 * Return the key of the current element
47
	 * @link http://php.net/manual/en/iterator.key.php
48
	 * @return mixed scalar on success, or null on failure.
49
	 * @since 5.0.0
50
	 */
51
	public function key()
52
	{
53
		return $this->objectStorage->current();
54
	}
55
56
	/**
57
	 * Checks if current position is valid
58
	 * @link http://php.net/manual/en/iterator.valid.php
59
	 * @return boolean The return value will be casted to boolean and then evaluated.
60
	 * Returns true on success or false on failure.
61
	 * @since 5.0.0
62
	 */
63
	public function valid()
64
	{
65
		return $this->objectStorage->valid();
66
	}
67
68
	/**
69
	 * Rewind the Iterator to the first element
70
	 * @link http://php.net/manual/en/iterator.rewind.php
71
	 * @return void Any returned value is ignored.
72
	 * @since 5.0.0
73
	 */
74
	public function rewind()
75
	{
76
		return $this->objectStorage->rewind();
77
	}
78
}