-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
284 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?php | ||
/** | ||
* functional: _IteratorAdapter.php | ||
*/ | ||
|
||
namespace Tarsana\Functional; | ||
|
||
/** | ||
* Provides an Iterator for a given associative SplObjectStorage collection which accesses the collection members like an ArrayIterator. | ||
* Class _IteratorAdapter | ||
* @package Tarsana\Functional | ||
* @internal | ||
*/ | ||
class _IteratorAdapter implements \Iterator | ||
{ | ||
private $objectStorage; | ||
|
||
public function __construct(\SplObjectStorage $theObjectStorage) | ||
{ | ||
$this->objectStorage = $theObjectStorage; | ||
} | ||
|
||
/** | ||
* Return the current element | ||
* @link http://php.net/manual/en/iterator.current.php | ||
* @return mixed Can return any type. | ||
* @since 5.0.0 | ||
*/ | ||
public function current() | ||
{ | ||
return $this->objectStorage->getInfo(); | ||
} | ||
|
||
/** | ||
* Move forward to next element | ||
* @link http://php.net/manual/en/iterator.next.php | ||
* @return void Any returned value is ignored. | ||
* @since 5.0.0 | ||
*/ | ||
public function next() | ||
{ | ||
return $this->objectStorage->next(); | ||
} | ||
|
||
/** | ||
* Return the key of the current element | ||
* @link http://php.net/manual/en/iterator.key.php | ||
* @return mixed scalar on success, or null on failure. | ||
* @since 5.0.0 | ||
*/ | ||
public function key() | ||
{ | ||
return $this->objectStorage->current(); | ||
} | ||
|
||
/** | ||
* Checks if current position is valid | ||
* @link http://php.net/manual/en/iterator.valid.php | ||
* @return boolean The return value will be casted to boolean and then evaluated. | ||
* Returns true on success or false on failure. | ||
* @since 5.0.0 | ||
*/ | ||
public function valid() | ||
{ | ||
return $this->objectStorage->valid(); | ||
} | ||
|
||
/** | ||
* Rewind the Iterator to the first element | ||
* @link http://php.net/manual/en/iterator.rewind.php | ||
* @return void Any returned value is ignored. | ||
* @since 5.0.0 | ||
*/ | ||
public function rewind() | ||
{ | ||
return $this->objectStorage->rewind(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters