aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/Aggregate.php49
-rw-r--r--Source/Append.php49
-rw-r--r--Source/Buffer.php237
-rw-r--r--Source/CallbackFilter.php49
-rw-r--r--Source/CallbackGenerator.php140
-rw-r--r--Source/Counter.php168
-rw-r--r--Source/Demultiplexer.php149
-rw-r--r--Source/Directory.php128
-rw-r--r--Source/Exception.php51
-rw-r--r--Source/FileSystem.php98
-rw-r--r--Source/Filter.php49
-rw-r--r--Source/Glob.php49
-rw-r--r--Source/Infinite.php49
-rw-r--r--Source/Iterator.php56
-rw-r--r--Source/IteratorIterator.php49
-rw-r--r--Source/Limit.php49
-rw-r--r--Source/Lookahead.php193
-rw-r--r--Source/Lookbehind.php179
-rw-r--r--Source/Map.php49
-rw-r--r--Source/Mock.php49
-rw-r--r--Source/Multiple.php101
-rw-r--r--Source/NoRewind.php49
-rw-r--r--Source/Outer.php49
-rw-r--r--Source/Recursive/CallbackFilter.php49
-rw-r--r--Source/Recursive/Directory.php164
-rw-r--r--Source/Recursive/Filter.php49
-rw-r--r--Source/Recursive/Iterator.php49
-rw-r--r--Source/Recursive/Map.php49
-rw-r--r--Source/Recursive/Mock.php146
-rw-r--r--Source/Recursive/Recursive.php56
-rw-r--r--Source/Recursive/RegularExpression.php121
-rw-r--r--Source/RegularExpression.php400
-rw-r--r--Source/Repeater.php176
-rw-r--r--Source/Seekable.php49
-rw-r--r--Source/SplFileInfo.php145
35 files changed, 3541 insertions, 0 deletions
diff --git a/Source/Aggregate.php b/Source/Aggregate.php
new file mode 100644
index 0000000..1abd0d8
--- /dev/null
+++ b/Source/Aggregate.php
@@ -0,0 +1,49 @@
+<?php
+
+/**
+ * Hoa
+ *
+ *
+ * @license
+ *
+ * New BSD License
+ *
+ * Copyright © 2007-2017, Hoa community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Hoa nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+namespace Hoa\Iterator;
+
+/**
+ * Interface \Hoa\Iterator\Aggregate.
+ *
+ * Extending the SPL IteratorAggregate interface.
+ *
+ * @copyright Copyright © 2007-2017 Hoa community
+ * @license New BSD License
+ */
+interface Aggregate extends \IteratorAggregate
+{
+}
diff --git a/Source/Append.php b/Source/Append.php
new file mode 100644
index 0000000..c98a008
--- /dev/null
+++ b/Source/Append.php
@@ -0,0 +1,49 @@
+<?php
+
+/**
+ * Hoa
+ *
+ *
+ * @license
+ *
+ * New BSD License
+ *
+ * Copyright © 2007-2017, Hoa community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Hoa nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+namespace Hoa\Iterator;
+
+/**
+ * Class \Hoa\Iterator\Append.
+ *
+ * Extending the SPL AppendIterator class.
+ *
+ * @copyright Copyright © 2007-2017 Hoa community
+ * @license New BSD License
+ */
+class Append extends \AppendIterator
+{
+}
diff --git a/Source/Buffer.php b/Source/Buffer.php
new file mode 100644
index 0000000..5e027b4
--- /dev/null
+++ b/Source/Buffer.php
@@ -0,0 +1,237 @@
+<?php
+
+/**
+ * Hoa
+ *
+ *
+ * @license
+ *
+ * New BSD License
+ *
+ * Copyright © 2007-2017, Hoa community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Hoa nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+namespace Hoa\Iterator;
+
+/**
+ * Class \Hoa\Iterator\Buffer.
+ *
+ * Buffer iterator: Can go backward up to a certain limit, and forward.
+ *
+ * @copyright Copyright © 2007-2017 Hoa community
+ * @license New BSD License
+ */
+class Buffer extends IteratorIterator implements Outer
+{
+ /**
+ * Buffer key index.
+ *
+ * @const int
+ */
+ const BUFFER_KEY = 0;
+
+ /**
+ * Buffer value index.
+ *
+ * @const int
+ */
+ const BUFFER_VALUE = 1;
+
+ /**
+ * Current iterator.
+ *
+ * @var \Iterator
+ */
+ protected $_iterator = null;
+
+ /**
+ * Buffer.
+ *
+ * @var \SplDoublyLinkedList
+ */
+ protected $_buffer = null;
+
+ /**
+ * Maximum buffer size.
+ *
+ * @var int
+ */
+ protected $_bufferSize = 1;
+
+
+
+ /**
+ * Construct.
+ *
+ * @param \Iterator $iterator Iterator.
+ * @param int $bufferSize Buffer size.
+ */
+ public function __construct(\Iterator $iterator, $bufferSize)
+ {
+ $this->_iterator = $iterator;
+ $this->_bufferSize = max($bufferSize, 1);
+ $this->_buffer = new \SplDoublyLinkedList();
+
+ return;
+ }
+
+ /**
+ * Get inner iterator.
+ *
+ * @return \Iterator
+ */
+ public function getInnerIterator()
+ {
+ return $this->_iterator;
+ }
+
+ /**
+ * Get buffer.
+ *
+ * @return \SplDoublyLinkedList
+ */
+ protected function getBuffer()
+ {
+ return $this->_buffer;
+ }
+
+ /**
+ * Get buffer size.
+ *
+ * @return int
+ */
+ public function getBufferSize()
+ {
+ return $this->_bufferSize;
+ }
+
+ /**
+ * Return the current element.
+ *
+ * @return mixed
+ */
+ public function current()
+ {
+ return $this->getBuffer()->current()[self::BUFFER_VALUE];
+ }
+
+ /**
+ * Return the key of the current element.
+ *
+ * @return mixed
+ */
+ public function key()
+ {
+ return $this->getBuffer()->current()[self::BUFFER_KEY];
+ }
+
+ /**
+ * Move forward to next element.
+ *
+ * @return void
+ */
+ public function next()
+ {
+ $innerIterator = $this->getInnerIterator();
+ $buffer = $this->getBuffer();
+
+ $buffer->next();
+
+ // End of the buffer, need a new value.
+ if (false === $buffer->valid()) {
+ for (
+ $bufferSize = count($buffer),
+ $maximumBufferSize = $this->getBufferSize();
+ $bufferSize >= $maximumBufferSize;
+ --$bufferSize
+ ) {
+ $buffer->shift();
+ }
+
+ $innerIterator->next();
+
+ $buffer->push([
+ self::BUFFER_KEY => $innerIterator->key(),
+ self::BUFFER_VALUE => $innerIterator->current()
+ ]);
+
+ // Seek to the end of the buffer.
+ $buffer->setIteratorMode($buffer::IT_MODE_LIFO | $buffer::IT_MODE_KEEP);
+ $buffer->rewind();
+ $buffer->setIteratorMode($buffer::IT_MODE_FIFO | $buffer::IT_MODE_KEEP);
+ }
+
+ return;
+ }
+
+ /**
+ * Move backward to previous element.
+ *
+ * @return void
+ */
+ public function previous()
+ {
+ $this->getBuffer()->prev();
+
+ return;
+ }
+
+ /**
+ * Rewind the iterator to the first element.
+ *
+ * @return void
+ */
+ public function rewind()
+ {
+ $innerIterator = $this->getInnerIterator();
+ $buffer = $this->getBuffer();
+
+ $innerIterator->rewind();
+
+ if (true === $buffer->isEmpty()) {
+ $buffer->push([
+ self::BUFFER_KEY => $innerIterator->key(),
+ self::BUFFER_VALUE => $innerIterator->current()
+ ]);
+ }
+
+ $buffer->rewind();
+
+ return;
+ }
+
+ /**
+ * Check if current position is valid.
+ *
+ * @return bool
+ */
+ public function valid()
+ {
+ return
+ $this->getBuffer()->valid() &&
+ $this->getInnerIterator()->valid();
+ }
+}
diff --git a/Source/CallbackFilter.php b/Source/CallbackFilter.php
new file mode 100644
index 0000000..d23cef8
--- /dev/null
+++ b/Source/CallbackFilter.php
@@ -0,0 +1,49 @@
+<?php
+
+/**
+ * Hoa
+ *
+ *
+ * @license
+ *
+ * New BSD License
+ *
+ * Copyright © 2007-2017, Hoa community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Hoa nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+namespace Hoa\Iterator;
+
+/**
+ * Class \Hoa\Iterator\CallbackFilter.
+ *
+ * Extending the SPL CallbackFilterIterator class.
+ *
+ * @copyright Copyright © 2007-2017 Hoa community
+ * @license New BSD License
+ */
+class CallbackFilter extends \CallbackFilterIterator
+{
+}
diff --git a/Source/CallbackGenerator.php b/Source/CallbackGenerator.php
new file mode 100644
index 0000000..4d4407a
--- /dev/null
+++ b/Source/CallbackGenerator.php
@@ -0,0 +1,140 @@
+<?php
+
+/**
+ * Hoa
+ *
+ *
+ * @license
+ *
+ * New BSD License
+ *
+ * Copyright © 2007-2017, Hoa community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Hoa nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+namespace Hoa\Iterator;
+
+/**
+ * Class \Hoa\Iterator\CallbackGenerator.
+ *
+ * Yield a value based on a callback.
+ *
+ * @copyright Copyright © 2007-2017 Hoa community
+ * @license New BSD License
+ */
+class CallbackGenerator implements Iterator
+{
+ /**
+ * Callback.
+ *
+ * @var callable
+ */
+ protected $_callback = null;
+
+ /**
+ * Current key.
+ *
+ * @var mixed
+ */
+ protected $_key = 0;
+
+ /**
+ * Current computed value.
+ *
+ * @var mixed
+ */
+ protected $_current = null;
+
+
+
+ /**
+ * Constructor.
+ *
+ * @param callable $callback Callback.
+ */
+ public function __construct(callable $callback)
+ {
+ $this->_callback = $callback;
+
+ return;
+ }
+
+ /**
+ * Return the current element.
+ *
+ * @return mixed
+ */
+ public function current()
+ {
+ $handle = $this->_callback;
+
+ return $this->_current = $handle($this->_key);
+ }
+
+ /**
+ * Return the key of the current element.
+ *
+ * @return mixed
+ */
+ public function key()
+ {
+ return $this->_key;
+ }
+
+ /**
+ * Move forward to next element.
+ *
+ * @return void
+ */
+ public function next()
+ {
+ ++$this->_key;
+
+ return;
+ }
+
+ /**
+ * Rewind the iterator to the first element.
+ *
+ * @return void
+ */
+ public function rewind()
+ {
+ $this->_key = 0;
+ $this->_current = null;
+
+ return;
+ }
+
+ /**
+ * Check if current position is valid.
+ *
+ * @return bool
+ */
+ public function valid()
+ {
+ return true;
+ }
+}
diff --git a/Source/Counter.php b/Source/Counter.php
new file mode 100644
index 0000000..3286399
--- /dev/null
+++ b/Source/Counter.php
@@ -0,0 +1,168 @@
+<?php
+
+/**
+ * Hoa
+ *
+ *
+ * @license
+ *
+ * New BSD License
+ *
+ * Copyright © 2007-2017, Hoa community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Hoa nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+namespace Hoa\Iterator;
+
+/**
+ * Class \Hoa\Iterator\Counter.
+ *
+ * A counter.
+ *
+ * @copyright Copyright © 2007-2017 Hoa community
+ * @license New BSD License
+ */
+class Counter implements Iterator
+{
+ /**
+ * From (lower bound).
+ *
+ * @var int
+ */
+ protected $_from = 0;
+
+ /**
+ * Current key.
+ *
+ * @var int
+ */
+ protected $_key = 0;
+
+ /**
+ * Current index.
+ *
+ * @var int
+ */
+ protected $_i = 0;
+
+ /**
+ * To (upper bound).
+ *
+ * @var int
+ */
+ protected $_to = 0;
+
+ /**
+ * Step.
+ *
+ * @var int
+ */
+ protected $_step = 0;
+
+
+
+ /**
+ * Constructor.
+ * Equivalent to:
+ * for($i = $from; $i < $to; $i += $step)
+ *
+ * @param int $from Start value.
+ * @param int $to Maximum value.
+ * @param int $step Step.
+ * @throws \Hoa\Iterator\Exception
+ */
+ public function __construct($from, $to, $step)
+ {
+ if ($step <= 0) {
+ throw new Exception(
+ 'The step must be non-negative; given %d.',
+ 0,
+ $step
+ );
+ }
+
+ $this->_from = $from;
+ $this->_to = $to;
+ $this->_step = $step;
+
+ return;
+ }
+
+ /**
+ * Return the current element.
+ *
+ * @return int
+ */
+ public function current()
+ {
+ return $this->_i;
+ }
+
+ /**
+ * Return the key of the current element.
+ *
+ * @return int
+ */
+ public function key()
+ {
+ return $this->_key;
+ }
+
+ /**
+ * Move forward to next element.
+ *
+ * @return void
+ */
+ public function next()
+ {
+ ++$this->_key;
+ $this->_i += $this->_step;
+
+ return;
+ }
+
+ /**
+ * Rewind the iterator to the first element.
+ *
+ * @return void
+ */
+ public function rewind()
+ {
+ $this->_key = 0;
+ $this->_i = $this->_from;
+
+ return;
+ }
+
+ /**
+ * Check if current position is valid.
+ *
+ * @return bool
+ */
+ public function valid()
+ {
+ return $this->_i < $this->_to;
+ }
+}
diff --git a/Source/Demultiplexer.php b/Source/Demultiplexer.php
new file mode 100644
index 0000000..108e692
--- /dev/null
+++ b/Source/Demultiplexer.php
@@ -0,0 +1,149 @@
+<?php
+
+/**
+ * Hoa
+ *
+ *
+ * @license
+ *
+ * New BSD License
+ *
+ * Copyright © 2007-2017, Hoa community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Hoa nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+namespace Hoa\Iterator;
+
+/**
+ * Class \Hoa\Iterator\Demultiplexer.
+ *
+ * Demux result from another iterator.
+ * This iterator is somehow the opposite of the Hoa\Iterator\Multiple iterator.
+ *
+ * @copyright Copyright © 2007-2017 Hoa community
+ * @license New BSD License
+ */
+class Demultiplexer implements Iterator
+{
+ /**
+ * Current iterator.
+ *
+ * @var \Traversable
+ */
+ protected $_iterator = null;
+
+ /**
+ * Current computed value.
+ *
+ * @var mixed
+ */
+ protected $_current = null;
+
+ /**
+ * Demuxer (callable to execute each time).
+ *
+ * @var callable
+ */
+ protected $_demuxer = null;
+
+
+
+ /**
+ * Constructor.
+ *
+ * @param \Traversable $iterator Iterator.
+ * @param callable $demuxer Demuxer.
+ * @throws \Hoa\Iterator\Exception
+ */
+ public function __construct(\Traversable $iterator, $demuxer)
+ {
+ if ($iterator instanceof \IteratorAggregate) {
+ $iterator = $iterator->getIterator();
+ }
+
+ $this->_iterator = $iterator;
+ $this->_demuxer = $demuxer;
+
+ return;
+ }
+
+ /**
+ * Return the current element.
+ *
+ * @return mixed
+ */
+ public function current()
+ {
+ if (null !== $this->_current) {
+ return $this->_current;
+ }
+
+ $demuxer = $this->_demuxer;
+
+ return $this->_current = $demuxer($this->_iterator->current());
+ }
+
+ /**
+ * Return the key of the current element.
+ *
+ * @return mixed
+ */
+ public function key()
+ {
+ return $this->_iterator->key();
+ }
+
+ /**
+ * Move forward to next element.
+ *
+ * @return void
+ */
+ public function next()
+ {
+ $this->_current = null;
+
+ return $this->_iterator->next();
+ }
+
+ /**
+ * Rewind the iterator to the first element.
+ *
+ * @return void
+ */
+ public function rewind()
+ {
+ return $this->_iterator->rewind();
+ }
+
+ /**
+ * Check if current position is valid.
+ *
+ * @return bool
+ */
+ public function valid()
+ {
+ return $this->_iterator->valid();
+ }
+}
diff --git a/Source/Directory.php b/Source/Directory.php
new file mode 100644
index 0000000..0d0431d
--- /dev/null
+++ b/Source/Directory.php
@@ -0,0 +1,128 @@
+<?php
+
+/**
+ * Hoa
+ *
+ *
+ * @license
+ *
+ * New BSD License
+ *
+ * Copyright © 2007-2017, Hoa community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Hoa nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+namespace Hoa\Iterator;
+
+/**
+ * Class \Hoa\Iterator\Directory.
+ *
+ * Extending the SPL DirectoryIterator class.
+ *
+ * @copyright Copyright © 2007-2017 Hoa community
+ * @license New BSD License
+ */
+class Directory extends \DirectoryIterator
+{
+ /**
+ * SplFileInfo classname.
+ *
+ * @var string
+ */
+ protected $_splFileInfoClass = null;
+
+ /**
+ * Relative path.
+ *
+ * @var string
+ */
+ protected $_relativePath = null;
+
+
+
+ /**
+ * Constructor.
+ * Please, see \DirectoryIterator::__construct() method.
+ * We add the $splFileInfoClass parameter.
+ *
+ * @param string $path Path.
+ * @param string $splFileInfoClass SplFileInfo classname.
+ */
+ public function __construct($path, $splFileInfoClass = null)
+ {
+ $this->_splFileInfoClass = $splFileInfoClass;
+ parent::__construct($path);
+ $this->setRelativePath($path);
+
+ return;
+ }
+
+ /**
+ * Current.
+ * Please, see \DirectoryIterator::current() method.
+ *
+ * @return mixed
+ */
+ public function current()
+ {
+ $out = parent::current();
+
+ if (null !== $this->_splFileInfoClass &&
+ $out instanceof \SplFileInfo) {
+ $out->setInfoClass($this->_splFileInfoClass);
+ $out = $out->getFileInfo();
+
+ if ($out instanceof \Hoa\Iterator\SplFileInfo) {
+ $out->setRelativePath($this->getRelativePath());
+ }
+ }
+
+ return $out;
+ }
+
+ /**
+ * Set relative path.
+ *
+ * @param string $relativePath Relative path.
+ * @return string
+ */
+ protected function setRelativePath($path)
+ {
+ $old = $this->_relativePath;
+ $this->_relativePath = $path;
+
+ return $old;
+ }
+
+ /**
+ * Get relative path (if given).
+ *
+ * @return string
+ */
+ public function getRelativePath()
+ {
+ return $this->_relativePath;
+ }
+}
diff --git a/Source/Exception.php b/Source/Exception.php
new file mode 100644
index 0000000..ce40b8c
--- /dev/null
+++ b/Source/Exception.php
@@ -0,0 +1,51 @@
+<?php
+
+/**
+ * Hoa
+ *
+ *
+ * @license
+ *
+ * New BSD License
+ *
+ * Copyright © 2007-2017, Hoa community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Hoa nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+namespace Hoa\Iterator;
+
+use Hoa\Exception as HoaException;
+
+/**
+ * Class \Hoa\Iterator\Exception.
+ *
+ * Extending the \Hoa\Exception\Exception class.
+ *
+ * @copyright Copyright © 2007-2017 Hoa community
+ * @license New BSD License
+ */
+class Exception extends HoaException
+{
+}
diff --git a/Source/FileSystem.php b/Source/FileSystem.php
new file mode 100644
index 0000000..b029997
--- /dev/null
+++ b/Source/FileSystem.php
@@ -0,0 +1,98 @@
+<?php
+
+/**
+ * Hoa
+ *
+ *
+ * @license
+ *
+ * New BSD License
+ *
+ * Copyright © 2007-2017, Hoa community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Hoa nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+namespace Hoa\Iterator;
+
+/**
+ * Class \Hoa\Iterator\FileSystem.
+ *
+ * Extending the SPL FileSystemIterator class.
+ *
+ * @copyright Copyright © 2007-2017 Hoa community
+ * @license New BSD License
+ */
+class FileSystem extends \FilesystemIterator
+{
+ /**
+ * SplFileInfo classname.
+ *
+ * @var string
+ */
+ protected $_splFileInfoClass = null;
+
+
+
+ /**
+ * Constructor.
+ * Please, see \FileSystemIterator::__construct() method.
+ * We add the $splFileInfoClass parameter.
+ *
+ * @param string $path Path.
+ * @param int $flags Flags.
+ * @param string $splFileInfoClass SplFileInfo classname.
+ */
+ public function __construct($path, $flags = null, $splFileInfoClass = null)
+ {
+ $this->_splFileInfoClass = $splFileInfoClass;
+
+ if (null === $flags) {
+ parent::__construct($path);
+ } else {
+ parent::__construct($path, $flags);
+ }
+
+ return;
+ }
+
+ /**
+ * Current.
+ * Please, see \FileSystemIterator::current() method.
+ *
+ * @return mixed
+ */
+ public function current()
+ {
+ $out = parent::current();
+
+ if (null !== $this->_splFileInfoClass &&
+ $out instanceof \SplFileInfo) {
+ $out->setInfoClass($this->_splFileInfoClass);
+ $out = $out->getFileInfo();
+ }
+
+ return $out;
+ }
+}
diff --git a/Source/Filter.php b/Source/Filter.php
new file mode 100644
index 0000000..aa2ecef
--- /dev/null
+++ b/Source/Filter.php
@@ -0,0 +1,49 @@
+<?php
+
+/**
+ * Hoa
+ *
+ *
+ * @license
+ *
+ * New BSD License
+ *
+ * Copyright © 2007-2017, Hoa community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Hoa nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+namespace Hoa\Iterator;
+
+/**
+ * Class \Hoa\Iterator\Filter.
+ *
+ * Extending the SPL FilterIterator class.
+ *
+ * @copyright Copyright © 2007-2017 Hoa community
+ * @license New BSD License
+ */
+abstract class Filter extends \FilterIterator
+{
+}
diff --git a/Source/Glob.php b/Source/Glob.php
new file mode 100644
index 0000000..f47458d
--- /dev/null
+++ b/Source/Glob.php
@@ -0,0 +1,49 @@
+<?php
+
+/**
+ * Hoa
+ *
+ *
+ * @license
+ *
+ * New BSD License
+ *
+ * Copyright © 2007-2017, Hoa community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Hoa nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+namespace Hoa\Iterator;
+
+/**
+ * Class \Hoa\Iterator\Glob.
+ *
+ * Extending the SPL GlobIterator class.
+ *
+ * @copyright Copyright © 2007-2017 Hoa community
+ * @license New BSD License
+ */
+class Glob extends \GlobIterator
+{
+}
diff --git a/Source/Infinite.php b/Source/Infinite.php
new file mode 100644
index 0000000..fce473f
--- /dev/null
+++ b/Source/Infinite.php
@@ -0,0 +1,49 @@
+<?php
+
+/**
+ * Hoa
+ *
+ *
+ * @license
+ *
+ * New BSD License
+ *
+ * Copyright © 2007-2017, Hoa community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Hoa nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+namespace Hoa\Iterator;
+
+/**
+ * Class \Hoa\Iterator\Infinite.
+ *
+ * Extending the SPL InfiniteIterator class.
+ *
+ * @copyright Copyright © 2007-2017 Hoa community
+ * @license New BSD License
+ */
+class Infinite extends \InfiniteIterator
+{
+}
diff --git a/Source/Iterator.php b/Source/Iterator.php
new file mode 100644
index 0000000..228d90d
--- /dev/null
+++ b/Source/Iterator.php
@@ -0,0 +1,56 @@
+<?php
+
+/**
+ * Hoa
+ *
+ *
+ * @license
+ *
+ * New BSD License
+ *
+ * Copyright © 2007-2017, Hoa community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Hoa nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+namespace Hoa\Iterator;
+
+use Hoa\Consistency;
+
+/**
+ * Interface \Hoa\Iterator.
+ *
+ * Extending the SPL Iterator interface.
+ *
+ * @copyright Copyright © 2007-2017 Hoa community
+ * @license New BSD License
+ */
+interface Iterator extends \Iterator
+{
+}
+
+/**
+ * Flex entity.
+ */
+Consistency::flexEntity('Hoa\Iterator\Iterator');
diff --git a/Source/IteratorIterator.php b/Source/IteratorIterator.php
new file mode 100644
index 0000000..376b22e
--- /dev/null
+++ b/Source/IteratorIterator.php
@@ -0,0 +1,49 @@
+<?php
+
+/**
+ * Hoa
+ *
+ *
+ * @license
+ *
+ * New BSD License
+ *
+ * Copyright © 2007-2017, Hoa community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Hoa nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+namespace Hoa\Iterator;
+
+/**
+ * Class \Hoa\Iterator\IteratorIterator.
+ *
+ * Extending the SPL IteratorIterator class.
+ *
+ * @copyright Copyright © 2007-2017 Hoa community
+ * @license New BSD License
+ */
+class IteratorIterator extends \IteratorIterator
+{
+}
diff --git a/Source/Limit.php b/Source/Limit.php
new file mode 100644
index 0000000..349bfd1
--- /dev/null
+++ b/Source/Limit.php
@@ -0,0 +1,49 @@
+<?php
+
+/**
+ * Hoa
+ *
+ *
+ * @license
+ *
+ * New BSD License
+ *
+ * Copyright © 2007-2017, Hoa community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Hoa nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+namespace Hoa\Iterator;
+
+/**
+ * Class \Hoa\Iterator\Limit.
+ *
+ * Extending the SPL LimitIterator class.
+ *
+ * @copyright Copyright © 2007-2017 Hoa community
+ * @license New BSD License
+ */
+class Limit extends \LimitIterator
+{
+}
diff --git a/Source/Lookahead.php b/Source/Lookahead.php
new file mode 100644
index 0000000..01eff9a
--- /dev/null
+++ b/Source/Lookahead.php
@@ -0,0 +1,193 @@
+<?php
+
+/**
+ * Hoa
+ *
+ *
+ * @license
+ *
+ * New BSD License
+ *
+ * Copyright © 2007-2017, Hoa community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Hoa nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+namespace Hoa\Iterator;
+
+/**
+ * Class \Hoa\Iterator\Lookahead.
+ *
+ * Look ahead iterator.
+ *
+ * @copyright Copyright © 2007-2017 Hoa community
+ * @license New BSD License
+ */
+class Lookahead extends IteratorIterator implements Outer
+{
+ /**
+ * Current iterator.
+ *
+ * @var \Iterator
+ */
+ protected $_iterator = null;
+
+ /**
+ * Current key.
+ *
+ * @var mixed
+ */
+ protected $_key = 0;
+
+ /**
+ * Current value.
+ *
+ * @var mixed
+ */
+ protected $_current = null;
+
+ /**
+ * Whether the current element is valid or not.
+ *
+ * @var bool
+ */
+ protected $_valid = false;
+
+
+
+ /**
+ * Construct.
+ *
+ * @param \Iterator $iterator Iterator.
+ */
+ public function __construct(\Iterator $iterator)
+ {
+ $this->_iterator = $iterator;
+
+ return;
+ }
+
+ /**
+ * Get inner iterator.
+ *
+ * @return \Iterator
+ */
+ public function getInnerIterator()
+ {
+ return $this->_iterator;
+ }
+
+ /**
+ * Return the current element.
+ *
+ * @return mixed
+ */
+ public function current()
+ {
+ return $this->_current;
+ }
+
+ /**
+ * Return the key of the current element.
+ *
+ * @return mixed
+ */
+ public function key()
+ {
+ return $this->_key;
+ }
+
+ /**
+ * Move forward to next element.
+ *
+ * @return void
+ */
+ public function next()
+ {
+ $innerIterator = $this->getInnerIterator();
+ $this->_valid = $innerIterator->valid();
+
+ if (false === $this->_valid) {
+ return;
+ }
+
+ $this->_key = $innerIterator->key();
+ $this->_current = $innerIterator->current();
+
+ return $innerIterator->next();
+ }
+
+ /**
+ * Rewind the iterator to the first element.
+ *
+ * @return void
+ */
+ public function rewind()
+ {
+ $out = $this->getInnerIterator()->rewind();
+ $this->next();
+
+ return $out;
+ }
+
+ /**
+ * Check if current position is valid.
+ *
+ * @return bool
+ */
+ public function valid()
+ {
+ return $this->_valid;
+ }
+
+ /**
+ * Check whether there is a next element.
+ *
+ * @return bool
+ */
+ public function hasNext()
+ {
+ return $this->getInnerIterator()->valid();
+ }
+
+ /**
+ * Get next value.
+ *
+ * @return mixed
+ */
+ public function getNext()
+ {
+ return $this->getInnerIterator()->current();
+ }
+
+ /**
+ * Get next key.
+ *
+ * @return mixed
+ */
+ public function getNextKey()
+ {
+ return $this->getInnerIterator()->key();
+ }
+}
diff --git a/Source/Lookbehind.php b/Source/Lookbehind.php
new file mode 100644
index 0000000..ba23e59
--- /dev/null
+++ b/Source/Lookbehind.php
@@ -0,0 +1,179 @@
+<?php
+
+/**
+ * Hoa
+ *
+ *
+ * @license
+ *
+ * New BSD License
+ *
+ * Copyright © 2007-2017, Hoa community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Hoa nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+namespace Hoa\Iterator;
+
+/**
+ * Class \Hoa\Iterator\Lookbehind.
+ *
+ * Look behind iterator.
+ *
+ * @copyright Copyright © 2007-2017 Hoa community
+ * @license New BSD License
+ */
+class Lookbehind extends IteratorIterator implements Outer
+{
+ /**
+ * Current iterator.
+ *
+ * @var \Iterator
+ */
+ protected $_iterator = null;
+
+ /**
+ * Previous key.
+ *
+ * @var mixed
+ */
+ protected $_previousKey = -1;
+
+ /**
+ * Previous value.
+ *
+ * @var mixed
+ */
+ protected $_previousCurrent = null;
+
+
+
+ /**
+ * Construct.
+ *
+ * @param \Iterator $iterator Iterator.
+ */
+ public function __construct(\Iterator $iterator)
+ {
+ $this->_iterator = $iterator;
+
+ return;
+ }
+
+ /**
+ * Get inner iterator.
+ *
+ * @return \Iterator
+ */
+ public function getInnerIterator()
+ {
+ return $this->_iterator;
+ }
+
+ /**
+ * Return the current element.
+ *
+ * @return mixed
+ */
+ public function current()
+ {
+ return $this->getInnerIterator()->current();
+ }
+
+ /**
+ * Return the key of the current element.
+ *
+ * @return mixed
+ */
+ public function key()
+ {
+ return $this->getInnerIterator()->key();
+ }
+
+ /**
+ * Move forward to next element.
+ *
+ * @return void
+ */
+ public function next()
+ {
+ $this->_previousKey = $this->key();
+ $this->_previousCurrent = $this->current();
+
+ return $this->getInnerIterator()->next();
+ }
+
+ /**
+ * Rewind the iterator to the first element.
+ *
+ * @return void
+ */
+ public function rewind()
+ {
+ $this->_previousKey = -1;
+ $this->_previousCurrent = null;
+
+ return $this->getInnerIterator()->rewind();
+ }
+
+ /**
+ * Check if current position is valid.
+ *
+ * @return bool
+ */
+ public function valid()
+ {
+ return $this->getInnerIterator()->valid();
+ }
+
+ /**
+ * Check whether there is a previous element.
+ *
+ * @return bool
+ */
+ public function hasPrevious()
+ {
+ return -1 !== $this->_previousKey;
+ }
+
+ /**
+ * Get previous value.
+ *
+ * @return mixed
+ */
+ public function getPrevious()
+ {
+ return $this->_previousCurrent;
+ }
+
+ /**
+ * Get previous key.
+ *
+ * @return mixed
+ */
+ public function getPreviousKey()
+ {
+ return $this->_previousKey;
+ }
+}
diff --git a/Source/Map.php b/Source/Map.php
new file mode 100644
index 0000000..8cb9447
--- /dev/null
+++ b/Source/Map.php
@@ -0,0 +1,49 @@
+<?php
+
+/**
+ * Hoa
+ *
+ *
+ * @license
+ *
+ * New BSD License
+ *
+ * Copyright © 2007-2017, Hoa community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Hoa nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+namespace Hoa\Iterator;
+
+/**
+ * Class \Hoa\Iterator\Map.
+ *
+ * Extending the SPL ArrayIterator class.
+ *
+ * @copyright Copyright © 2007-2017 Hoa community
+ * @license New BSD License
+ */
+class Map extends \ArrayIterator
+{
+}
diff --git a/Source/Mock.php b/Source/Mock.php
new file mode 100644
index 0000000..3d0d457
--- /dev/null
+++ b/Source/Mock.php
@@ -0,0 +1,49 @@
+<?php
+
+/**
+ * Hoa
+ *
+ *
+ * @license
+ *
+ * New BSD License
+ *
+ * Copyright © 2007-2017, Hoa community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Hoa nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+namespace Hoa\Iterator;
+
+/**
+ * Class \Hoa\Iterator\Mock.
+ *
+ * Extending the SPL EmptyIterator class.
+ *
+ * @copyright Copyright © 2007-2017 Hoa community
+ * @license New BSD License
+ */
+class Mock extends \EmptyIterator
+{
+}
diff --git a/Source/Multiple.php b/Source/Multiple.php
new file mode 100644
index 0000000..a8154e6
--- /dev/null
+++ b/Source/Multiple.php
@@ -0,0 +1,101 @@
+<?php
+
+/**
+ * Hoa
+ *
+ *
+ * @license
+ *
+ * New BSD License
+ *
+ * Copyright © 2007-2017, Hoa community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Hoa nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+namespace Hoa\Iterator;
+
+/**
+ * Class \Hoa\Iterator\Multiple.
+ *
+ * Extending the SPL MultipleIterator class.
+ *
+ * @copyright Copyright © 2007-2017 Hoa community
+ * @license New BSD License
+ */
+class Multiple extends \MultipleIterator
+{
+ /**
+ * Default value for each $infos.
+ *
+ * @var array
+ */
+ protected $_infos = [];
+
+
+
+ /**
+ * Attach iterator informations.
+ * Add the $default argument that will be use when the iterator has reached
+ * its end.
+ *
+ * @param \Iterator $iterator Iterator.
+ * @param string $infos Informations to attach.
+ * @param mixed $default Default value.
+ * @return void
+ */
+ public function attachIterator(
+ \Iterator $iterator,
+ $infos = null,
+ $default = null
+ ) {
+ $out = parent::attachIterator($iterator, $infos);
+
+ if (null === $infos) {
+ $this->_infos[] = $default;
+ } else {
+ $this->_infos[$infos] = $default;
+ }
+
+ return $out;
+ }
+
+ /**
+ * Get the registered iterator instances.
+ *
+ * @return array
+ */
+ public function current()
+ {
+ $out = parent::current();
+
+ foreach ($out as $key => &$value) {
+ if (null === $value) {
+ $value = $this->_infos[$key];
+ }
+ }
+
+ return $out;
+ }
+}
diff --git a/Source/NoRewind.php b/Source/NoRewind.php
new file mode 100644
index 0000000..9af8bbe
--- /dev/null
+++ b/Source/NoRewind.php
@@ -0,0 +1,49 @@
+<?php
+
+/**
+ * Hoa
+ *
+ *
+ * @license
+ *
+ * New BSD License
+ *
+ * Copyright © 2007-2017, Hoa community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Hoa nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+namespace Hoa\Iterator;
+
+/**
+ * Class \Hoa\Iterator\NoRewind.
+ *
+ * Extending the SPL NoRewindIterator class.
+ *
+ * @copyright Copyright © 2007-2017 Hoa community
+ * @license New BSD License
+ */
+class NoRewind extends \NoRewindIterator
+{
+}
diff --git a/Source/Outer.php b/Source/Outer.php
new file mode 100644
index 0000000..7299846
--- /dev/null
+++ b/Source/Outer.php
@@ -0,0 +1,49 @@
+<?php
+
+/**
+ * Hoa
+ *
+ *
+ * @license
+ *
+ * New BSD License
+ *
+ * Copyright © 2007-2017, Hoa community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Hoa nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+namespace Hoa\Iterator;
+
+/**
+ * Interface \Hoa\Iterator\Outer.
+ *
+ * Extending the SPL OuterIterator interface.
+ *
+ * @copyright Copyright © 2007-2017 Hoa community
+ * @license New BSD License
+ */
+interface Outer extends \OuterIterator
+{
+}
diff --git a/Source/Recursive/CallbackFilter.php b/Source/Recursive/CallbackFilter.php
new file mode 100644
index 0000000..d4caa88
--- /dev/null
+++ b/Source/Recursive/CallbackFilter.php
@@ -0,0 +1,49 @@
+<?php
+
+/**
+ * Hoa
+ *
+ *
+ * @license
+ *
+ * New BSD License
+ *
+ * Copyright © 2007-2017, Hoa community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Hoa nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+namespace Hoa\Iterator\Recursive;
+
+/**
+ * Class \Hoa\Iterator\Recursive\CallbackFilter.
+ *
+ * Extending the SPL RecursiveCallbackFilterIterator class.
+ *
+ * @copyright Copyright © 2007-2017 Hoa community
+ * @license New BSD License
+ */
+class CallbackFilter extends \RecursiveCallbackFilterIterator
+{
+}
diff --git a/Source/Recursive/Directory.php b/Source/Recursive/Directory.php
new file mode 100644
index 0000000..55421d3
--- /dev/null
+++ b/Source/Recursive/Directory.php
@@ -0,0 +1,164 @@
+<?php
+
+/**
+ * Hoa
+ *
+ *
+ * @license
+ *
+ * New BSD License
+ *
+ * Copyright © 2007-2017, Hoa community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Hoa nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+namespace Hoa\Iterator\Recursive;
+
+/**
+ * Class \Hoa\Iterator\Recursive\Directory.
+ *
+ * Extending the SPL RecursiveDirectoryIterator class.
+ *
+ * @copyright Copyright © 2007-2017 Hoa community
+ * @license New BSD License
+ */
+class Directory extends \RecursiveDirectoryIterator
+{
+ /**
+ * SplFileInfo classname.
+ *
+ * @var string
+ */
+ protected $_splFileInfoClass = null;
+
+ /**
+ * Relative path.
+ *
+ * @var string
+ */
+ protected $_relativePath = 0;
+
+ /**
+ * Workaround for the bug #65136.
+ *
+ * @var string
+ */
+ private static $_handlePath = null;
+
+
+
+ /**
+ * Constructor.
+ * Please, see \RecursiveDirectoryIterator::__construct() method.
+ * We add the $splFileInfoClass parameter.
+ *
+ * @param string $path Path.
+ * @param int $flags Flags.
+ * @param string $splFileInfoClass SplFileInfo classname.
+ */
+ public function __construct($path, $flags = null, $splFileInfoClass = null)
+ {
+ if (null === $flags) {
+ parent::__construct($path);
+ } else {
+ parent::__construct($path, $flags);
+ }
+
+ if (null !== self::$_handlePath) {
+ $this->_relativePath = self::$_handlePath;
+ self::$_handlePath = null;
+ } else {
+ $this->_relativePath = $path;
+ }
+
+ $this->setSplFileInfoClass($splFileInfoClass);
+
+ return;
+ }
+
+ /**
+ * Current.
+ * Please, see \RecursiveDirectoryIterator::current() method.
+ *
+ * @return mixed
+ */
+ public function current()
+ {
+ $out = parent::current();
+
+ if (null !== $this->_splFileInfoClass &&
+ $out instanceof \SplFileInfo) {
+ $out->setInfoClass($this->_splFileInfoClass);
+ $out = $out->getFileInfo();
+
+ if ($out instanceof \Hoa\Iterator\SplFileInfo) {
+ $out->setRelativePath($this->getRelativePath());
+ }
+ }
+
+ return $out;
+ }
+
+ /**
+ * Get children.
+ * Please, see \RecursiveDirectoryIterator::getChildren() method.
+ *
+ * @return mixed
+ */
+ public function getChildren()
+ {
+ self::$_handlePath = $this->getRelativePath();
+ $out = parent::getChildren();
+
+ if ($out instanceof \RecursiveDirectoryIterator) {
+ $out->setSplFileInfoClass($this->_splFileInfoClass);
+ }
+
+ return $out;
+ }
+
+ /**
+ * Set SplFileInfo classname.
+ *
+ * @param string $splFileInfoClass SplFileInfo classname.
+ * @return void
+ */
+ public function setSplFileInfoClass($splFileInfoClass)
+ {
+ $this->_splFileInfoClass = $splFileInfoClass;
+
+ return;
+ }
+
+ /**
+ * Get relative path (if given).
+ *
+ * @return string
+ */
+ public function getRelativePath()
+ {
+ return $this->_relativePath;
+ }
+}
diff --git a/Source/Recursive/Filter.php b/Source/Recursive/Filter.php
new file mode 100644
index 0000000..cf6e98b
--- /dev/null
+++ b/Source/Recursive/Filter.php
@@ -0,0 +1,49 @@
+<?php
+
+/**
+ * Hoa
+ *
+ *
+ * @license
+ *
+ * New BSD License
+ *
+ * Copyright © 2007-2017, Hoa community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Hoa nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+namespace Hoa\Iterator\Recursive;
+
+/**
+ * Class \Hoa\Iterator\Recursive\Filter.
+ *
+ * Extending the SPL RecursiveFilterIterator class.
+ *
+ * @copyright Copyright © 2007-2017 Hoa community
+ * @license New BSD License
+ */
+abstract class Filter extends \RecursiveFilterIterator
+{
+}
diff --git a/Source/Recursive/Iterator.php b/Source/Recursive/Iterator.php
new file mode 100644
index 0000000..a7b4ccd
--- /dev/null
+++ b/Source/Recursive/Iterator.php
@@ -0,0 +1,49 @@
+<?php
+
+/**
+ * Hoa
+ *
+ *
+ * @license
+ *
+ * New BSD License
+ *
+ * Copyright © 2007-2017, Hoa community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Hoa nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+namespace Hoa\Iterator\Recursive;
+
+/**
+ * Class \Hoa\Iterator\Recursive\Iterator.
+ *
+ * Extending the SPL RecursiveIteratorIterator class.
+ *
+ * @copyright Copyright © 2007-2017 Hoa community
+ * @license New BSD License
+ */
+class Iterator extends \RecursiveIteratorIterator
+{
+}
diff --git a/Source/Recursive/Map.php b/Source/Recursive/Map.php
new file mode 100644
index 0000000..4743424
--- /dev/null
+++ b/Source/Recursive/Map.php
@@ -0,0 +1,49 @@
+<?php
+
+/**
+ * Hoa
+ *
+ *
+ * @license
+ *
+ * New BSD License
+ *
+ * Copyright © 2007-2017, Hoa community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Hoa nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+namespace Hoa\Iterator\Recursive;
+
+/**
+ * Class \Hoa\Iterator\Recursive\Map.
+ *
+ * Extending the SPL RecursiveArrayIterator class.
+ *
+ * @copyright Copyright © 2007-2017 Hoa community
+ * @license New BSD License
+ */
+class Map extends \RecursiveArrayIterator
+{
+}
diff --git a/Source/Recursive/Mock.php b/Source/Recursive/Mock.php
new file mode 100644
index 0000000..6f13365
--- /dev/null
+++ b/Source/Recursive/Mock.php
@@ -0,0 +1,146 @@
+<?php
+
+/**
+ * Hoa
+ *
+ *
+ * @license
+ *
+ * New BSD License
+ *
+ * Copyright © 2007-2017, Hoa community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Hoa nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+namespace Hoa\Iterator\Recursive;
+
+/**
+ * Class \Hoa\Iterator\Recursive\Mock.
+ *
+ * Mock a recursive iterator with no children.
+ * It allows to use regular iterators with a recursive iterator iterator.
+ *
+ * @copyright Copyright © 2007-2017 Hoa community
+ * @license New BSD License
+ */
+class Mock implements Recursive
+{
+ /**
+ * Current iterator.
+ *
+ * @var \Traversable
+ */
+ protected $_iterator = null;
+
+
+
+ /**
+ * Constructor.
+ *
+ * @param \Traversable $iterator Iterator.
+ */
+ public function __construct(\Traversable $iterator)
+ {
+ if ($iterator instanceof \IteratorAggregate) {
+ $iterator = $iterator->getIterator();
+ }
+
+ $this->_iterator = $iterator;
+
+ return;
+ }
+
+ /**
+ * Return the current element.
+ *
+ * @return mixed
+ */
+ public function current()
+ {
+ return $this->_iterator->current();
+ }
+
+ /**
+ * Return the key of the current element.
+ *
+ * @return mixed
+ */
+ public function key()
+ {
+ return $this->_iterator->key();
+ }
+
+ /**
+ * Move forward to next element.
+ *
+ * @return void
+ */
+ public function next()
+ {
+ return $this->_iterator->next();
+ }
+
+ /**
+ * Rewind the iterator to the first element.
+ *
+ * @return void
+ */
+ public function rewind()
+ {
+ return $this->_iterator->rewind();
+ }
+
+ /**
+ * Check if current position is valid.
+ *
+ * @return bool
+ */
+ public function valid()
+ {
+ return $this->_iterator->valid();
+ }
+
+ /**
+ * Return an iterator for the current entry.
+ * It's a fake, we return null.
+ *
+ * @return void
+ */
+ public function getChildren()
+ {
+ return null;
+ }
+
+ /**
+ * Return if an iterator can be created for the current entry.
+ * It's a fake, we return false.
+ *
+ * @return bool
+ */
+ public function hasChildren()
+ {
+ return false;
+ }
+}
diff --git a/Source/Recursive/Recursive.php b/Source/Recursive/Recursive.php
new file mode 100644
index 0000000..730c1e1
--- /dev/null
+++ b/Source/Recursive/Recursive.php
@@ -0,0 +1,56 @@
+<?php
+
+/**
+ * Hoa
+ *
+ *
+ * @license
+ *
+ * New BSD License
+ *
+ * Copyright © 2007-2017, Hoa community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Hoa nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+namespace Hoa\Iterator\Recursive;
+
+use Hoa\Consistency;
+
+/**
+ * Class \Hoa\Iterator\Recursive.
+ *
+ * Extending the SPL RecursiveIterator interface.
+ *
+ * @copyright Copyright © 2007-2017 Hoa community
+ * @license New BSD License
+ */
+interface Recursive extends \RecursiveIterator
+{
+}
+
+/**
+ * Flex entity.
+ */
+Consistency::flexEntity('Hoa\Iterator\Recursive\Recursive');
diff --git a/Source/Recursive/RegularExpression.php b/Source/Recursive/RegularExpression.php
new file mode 100644
index 0000000..6368be9
--- /dev/null
+++ b/Source/Recursive/RegularExpression.php
@@ -0,0 +1,121 @@
+<?php
+
+/**
+ * Hoa
+ *
+ *
+ * @license
+ *
+ * New BSD License
+ *
+ * Copyright © 2007-2017, Hoa community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Hoa nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+namespace Hoa\Iterator\Recursive;
+
+use Hoa\Iterator;
+
+/**
+ * Class \Hoa\Iterator\Recursive\RegularExpression.
+ *
+ * Re-implement the SPL RecursiveRegexIterator class.
+ * There are too many bugs in php-src and HHVM, so we re-implement it from
+ * scratch without extending the existing class.
+ *
+ * Inspired by hhvm://hphp/system/php/spl/iterators/RecursiveRegexIterator.php
+ *
+ * @copyright Copyright © 2007-2017 Hoa community
+ * @license New BSD License
+ */
+class RegularExpression extends Iterator\RegularExpression implements Recursive
+{
+ /**
+ * Constructor.
+ *
+ * @param \RecursiveIterator $iterator The recursive iterator to
+ * apply this regex filter to.
+ * @param string $regex The regular expression to
+ * match.
+ * @param int $mode Operation mode, please see the
+ * \RegexIterator::setMode method.
+ * @param int $flags Special flags, please see the
+ * \RegexIterator::setFlags method.
+ * @param int $pregFlags Regular expression flags,
+ * please see
+ * \RegexIterator constants.
+ */
+ public function __construct(
+ \RecursiveIterator $iterator,
+ $regex,
+ $mode = self::MATCH,
+ $flags = 0,
+ $pregFlags = 0
+ ) {
+ parent::__construct($iterator, $regex, $mode, $flags, $pregFlags);
+
+ return;
+ }
+
+ /**
+ * Get accept status.
+ *
+ * @return bool
+ */
+ public function accept()
+ {
+ return
+ true === $this->hasChildren() ||
+ true === parent::accept();
+ }
+
+ /**
+ * Get an iterator for the current entry.
+ *
+ * @return \Hoa\Iterator\Recursive\RegularExpression
+ */
+ public function getChildren()
+ {
+ return new static(
+ true === $this->hasChildren()
+ ? $this->getInnerIterator()->getChildren()
+ : null,
+ $this->getRegex(),
+ $this->getMode(),
+ $this->getFlags(),
+ $this->getPregFlags()
+ );
+ }
+
+ /**
+ * Check whether an iterator can be obtained for the current entry.
+ *
+ * @return bool
+ */
+ public function hasChildren()
+ {
+ return $this->getInnerIterator()->hasChildren();
+ }
+}
diff --git a/Source/RegularExpression.php b/Source/RegularExpression.php
new file mode 100644
index 0000000..f26cb5e
--- /dev/null
+++ b/Source/RegularExpression.php
@@ -0,0 +1,400 @@
+<?php
+
+/**
+ * Hoa
+ *
+ *
+ * @license
+ *
+ * New BSD License
+ *
+ * Copyright © 2007-2017, Hoa community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Hoa nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+namespace Hoa\Iterator;
+
+/**
+ * Class \Hoa\Iterator\RegularExpression.
+ *
+ * Re-implement the SPL RegexIterator class.
+ * There are too many bugs in php-src and HHVM, so we re-implement it from
+ * scratch without extending the existing class.
+ *
+ * Inspired by hhvm://hphp/system/php/spl/iterators/RegexIterator.php
+ *
+ * @copyright Copyright © 2007-2017 Hoa community
+ * @license New BSD License
+ */
+class RegularExpression extends Filter
+{
+ /**
+ * Flag: match the entry key instead of the entry value.
+ *
+ * @const int
+ */
+ const USE_KEY = 1;
+
+ /**
+ * Flag: invert match.
+ *
+ * @const int
+ */
+ const INVERT_MATCH = 2;
+
+ /**
+ * Mode and preg flag: only execute match (filter) for the current entry.
+ *
+ * @const int
+ */
+ const MATCH = 0;
+
+ /**
+ * Mode and preg flag: first match for the current entry.
+ *
+ * @const int
+ */
+ const GET_MATCH = 1;
+
+ /**
+ * Mode and preg flag: all matches for the current entry.
+ *
+ * @const int
+ */
+ const ALL_MATCHES = 2;
+
+ /**
+ * Mode and preg flag: split values for the current entry.
+ *
+ * @const int
+ */
+ const SPLIT = 3;
+
+ /**
+ * Mode and preg flag: replace the current entry.
+ *
+ * @const int
+ */
+ const REPLACE = 4;
+
+ /**
+ * The regular expression to match.
+ *
+ * @var string
+ */
+ protected $_regex = null;
+
+ /**
+ * Operation mode, see the \RegexIterator::setMode method for a list of
+ * modes.
+ *
+ * @var int
+ */
+ protected $_mode = 0;
+
+ /**
+ * Special flags, see the \RegexIterator::setFlag method for a list of
+ * available flags.
+ *
+ * @var int
+ */
+ protected $_flags = 0;
+
+ /**
+ * The regular expression flags. See constants.
+ *
+ * @var int
+ */
+ protected $_pregFlags = 0;
+
+ /**
+ * Current key.
+ *
+ * @var int
+ */
+ protected $_key = 0;
+
+ /**
+ * Current value.
+ *
+ * @var string
+ */
+ protected $_current = null;
+
+ /**
+ * Replacement.
+ *
+ * @var string
+ */
+ public $replacement = null;
+
+
+
+ /**
+ * Constructor.
+ *
+ * @param \RecursiveIterator $iterator The recursive iterator to
+ * apply this regex filter to.
+ * @param string $regex The regular expression to
+ * match.
+ * @param int $mode Operation mode, please see the
+ * \RegexIterator::setMode method.
+ * @param int $flags Special flags, please see the
+ * \RegexIterator::setFlags method.
+ * @param int $pregFlags Regular expression flags,
+ * please see
+ * \RegexIterator constants.
+ */
+ public function __construct(
+ \Iterator $iterator,
+ $regex,
+ $mode = self::MATCH,
+ $flags = 0,
+ $pregFlags = 0
+ ) {
+ parent::__construct($iterator);
+
+ $this->_regex = $regex;
+ $this->setMode($mode);
+ $this->setFlags($flags);
+ $this->setPregFlags($pregFlags);
+ $this->replacement = null;
+
+ return;
+ }
+
+ /**
+ * Get accept status.
+ *
+ * @return bool
+ */
+ public function accept()
+ {
+ if (is_array(parent::current())) {
+ return false;
+ }
+
+ $this->_key = parent::key();
+ $this->_current = parent::current();
+
+ $matches = [];
+ $useKey = $this->_flags & self::USE_KEY;
+ $subject = $useKey ? $this->_key : $this->_current;
+ $out = false;
+
+ switch ($this->_mode) {
+
+ case self::MATCH:
+ $out = 0 !== preg_match(
+ $this->_regex,
+ $subject,
+ $matches,
+ $this->_pregFlags
+ );
+
+ break;
+
+ case self::GET_MATCH:
+ $this->_current = [];
+ $out = 0 !== preg_match(
+ $this->_regex,
+ $subject,
+ $this->_current,
+ $this->_pregFlags
+ );
+
+ break;
+
+ case self::ALL_MATCHES:
+ $this->_current = [];
+ $out = 0 < preg_match_all(
+ $this->_regex,
+ $subject,
+ $this->_current,
+ $this->_pregFlags
+ );
+
+ break;
+
+ case self::SPLIT:
+ $this->_current = preg_split(
+ $this->_regex,
+ $subject,
+ null,
+ $this->_pregFlags
+ );
+
+ $out =
+ is_array($this->_current) &&
+ 1 < count($this->_current);
+
+ break;
+
+ case self::REPLACE:
+ $numberOfReplacement = 0;
+ $result = preg_replace(
+ $this->_regex,
+ $this->replacement,
+ $subject,
+ -1,
+ $numberOfReplacement
+ );
+
+ if (null === $result || 0 === $numberOfReplacement) {
+ $out = false;
+
+ break;
+ }
+
+ if (0 !== $useKey) {
+ $this->_key = $result;
+ $out = true;
+
+ break;
+ }
+
+ $this->_current = $result;
+ $out = true;
+
+ break;
+
+ default:
+ $out = false;
+
+ break;
+ }
+
+ if (0 !== ($this->_flags & self::INVERT_MATCH)) {
+ return false === $out;
+ }
+
+ return $out;
+ }
+
+ /**
+ * Get current key.
+ *
+ * @return int
+ */
+ public function key()
+ {
+ return $this->_key;
+ }
+
+ /**
+ * Get current value.
+ *
+ * @return string
+ */
+ public function current()
+ {
+ return $this->_current;
+ }
+
+ /**
+ * Set mode.
+ *
+ * @param int $mode Mode.
+ * @return void
+ */
+ public function setMode($mode)
+ {
+ if ($mode < self::MATCH || $mode > self::REPLACE) {
+ throw new \InvalidArgumentException(
+ 'Illegal mode ' . $mode . '.'
+ );
+ }
+
+ $this->_mode = $mode;
+
+ return;
+ }
+
+ /**
+ * Set flags.
+ *
+ * @param int $flags Flags.
+ * @return void
+ */
+ public function setFlags($flags)
+ {
+ $this->_flags = $flags;
+
+ return;
+ }
+
+ /**
+ * Set preg flags.
+ *
+ * @param int $pregFlags Preg flags.
+ * @return void
+ */
+ public function setPregFlags($pregFlags)
+ {
+ $this->_pregFlags = $pregFlags;
+
+ return;
+ }
+
+ /**
+ * Get regular expression.
+ *
+ * @return string
+ */
+ public function getRegex()
+ {
+ return $this->_regex;
+ }
+
+ /**
+ * Get mode.
+ *
+ * @return int
+ */
+ public function getMode()
+ {
+ return $this->_mode;
+ }
+
+ /**
+ * Get flags.
+ *
+ * @return int
+ */
+ public function getFlags()
+ {
+ return $this->_flags;
+ }
+
+ /**
+ * Get preg flags.
+ *
+ * @return int
+ */
+ public function getPregFlags()
+ {
+ return $this->_pregFlags;
+ }
+}
diff --git a/Source/Repeater.php b/Source/Repeater.php
new file mode 100644
index 0000000..0b9fd66
--- /dev/null
+++ b/Source/Repeater.php
@@ -0,0 +1,176 @@
+<?php
+
+/**
+ * Hoa
+ *
+ *
+ * @license
+ *
+ * New BSD License
+ *
+ * Copyright © 2007-2017, Hoa community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Hoa nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+namespace Hoa\Iterator;
+
+/**
+ * Class \Hoa\Iterator\Repeater.
+ *
+ * Repeat an iterator n-times.
+ *
+ * @copyright Copyright © 2007-2017 Hoa community
+ * @license New BSD License
+ */
+class Repeater implements Iterator
+{
+ /**
+ * Current iterator.
+ *
+ * @var \Traversable
+ */
+ protected $_iterator = null;
+
+ /**
+ * Maximum repetition.
+ *
+ * @var int
+ */
+ protected $_n = 1;
+
+ /**
+ * Current repetition.
+ *
+ * @var int
+ */
+ protected $_i = 1;
+
+ /**
+ * Body (callable to execute each time).
+ *
+ * @var callable
+ */
+ protected $_body = null;
+
+
+
+ /**
+ * Constructor.
+ *
+ * @param \Traversable $iterator Iterator.
+ * @param int $n Repeat $n-times.
+ * @param callable $body Body.
+ * @throws \Hoa\Iterator\Exception
+ */
+ public function __construct(\Traversable $iterator, $n, $body = null)
+ {
+ if (0 >= $n) {
+ throw new Exception(
+ 'n must be greater than 0, given %d.',
+ 0,
+ $n
+ );
+ }
+
+ if ($iterator instanceof \IteratorAggregate) {
+ $iterator = $iterator->getIterator();
+ }
+
+ $this->_iterator = $iterator;
+ $this->_n = $n;
+ $this->_body = $body;
+
+ return;
+ }
+
+ /**
+ * Return the current element.
+ *
+ * @return mixed
+ */
+ public function current()
+ {
+ return $this->_iterator->current();
+ }
+
+ /**
+ * Return the key of the current element.
+ *
+ * @return mixed
+ */
+ public function key()
+ {
+ return $this->_iterator->key();
+ }
+
+ /**
+ * Move forward to next element.
+ *
+ * @return void
+ */
+ public function next()
+ {
+ return $this->_iterator->next();
+ }
+
+ /**
+ * Rewind the iterator to the first element.
+ *
+ * @return void
+ */
+ public function rewind()
+ {
+ return $this->_iterator->rewind();
+ }
+
+ /**
+ * Check if current position is valid.
+ *
+ * @return bool
+ */
+ public function valid()
+ {
+ $valid = $this->_iterator->valid();
+
+ if (true === $valid) {
+ return true;
+ }
+
+ if (null !== $this->_body) {
+ $handle = &$this->_body;
+ $handle($this->_i);
+ }
+
+ $this->rewind();
+
+ if ($this->_n <= $this->_i++) {
+ $this->_i = 1;
+
+ return false;
+ }
+
+ return true;
+ }
+}
diff --git a/Source/Seekable.php b/Source/Seekable.php
new file mode 100644
index 0000000..2656ffc
--- /dev/null
+++ b/Source/Seekable.php
@@ -0,0 +1,49 @@
+<?php
+
+/**
+ * Hoa
+ *
+ *
+ * @license
+ *
+ * New BSD License
+ *
+ * Copyright © 2007-2017, Hoa community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Hoa nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+namespace Hoa\Iterator;
+
+/**
+ * Interface \Hoa\IteratorSeekable.
+ *
+ * Extending the SPL SeekableIterator interface.
+ *
+ * @copyright Copyright © 2007-2017 Hoa community
+ * @license New BSD License
+ */
+interface Seekable extends \SeekableIterator
+{
+}
diff --git a/Source/SplFileInfo.php b/Source/SplFileInfo.php
new file mode 100644
index 0000000..af8c9a1
--- /dev/null
+++ b/Source/SplFileInfo.php
@@ -0,0 +1,145 @@
+<?php
+
+/**
+ * Hoa
+ *
+ *
+ * @license
+ *
+ * New BSD License
+ *
+ * Copyright © 2007-2017, Hoa community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Hoa nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+namespace Hoa\Iterator;
+
+/**
+ * Class \Hoa\Iterator\SplFileInfo.
+ *
+ * Enhance SplFileInfo implementation.
+ *
+ * @copyright Copyright © 2007-2017 Hoa community
+ * @license New BSD License
+ */
+class SplFileInfo extends \SplFileInfo
+{
+ /**
+ * Hash.
+ *
+ * @var string
+ */
+ protected $_hash = null;
+
+ /**
+ * Relative path.
+ *
+ * @var string
+ */
+ protected $_relativePath = null;
+
+
+
+ /**
+ * Construct.
+ *
+ * @param string $filename Filename.
+ * @param string $relativePath Relative path.
+ */
+ public function __construct($filename, $relativePath = null)
+ {
+ parent::__construct($filename);
+
+ if (-1 !== $mtime = $this->getMTime()) {
+ $this->_hash = md5($this->getPathname() . $mtime);
+ }
+
+ $this->_relativePath = $relativePath;
+
+ return;
+ }
+
+ /**
+ * Get the hash.
+ *
+ * @return string
+ */
+ public function getHash()
+ {
+ return $this->_hash;
+ }
+
+ /**
+ * Get the MTime.
+ *
+ * @return int
+ */
+ public function getMTime()
+ {
+ try {
+ return parent::getMTime();
+ } catch (\RuntimeException $e) {
+ return -1;
+ }
+ }
+
+ /**
+ * Set relative path.
+ *
+ * @param string $relativePath Relative path.
+ * @return string
+ */
+ public function setRelativePath($relativePath)
+ {
+ $old = $this->_relativePath;
+ $this->_relativePath = $relativePath;
+
+ return $old;
+ }
+
+ /**
+ * Get relative path (if given).
+ *
+ * @return string
+ */
+ public function getRelativePath()
+ {
+ return $this->_relativePath;
+ }
+
+ /**
+ * Get relative pathname (if possible).
+ *
+ * @return string
+ */
+ public function getRelativePathname()
+ {
+ if (null === $relative = $this->getRelativePath()) {
+ return $this->getPathname();
+ }
+
+ return substr($this->getPathname(), strlen($relative));
+ }
+}