Last active
June 11, 2022 20:35
-
-
Save coisa/a981af1fd8ddd58589ed12189409698e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| <?php | |
| namespace CoiSA\Iterator\IteratorIterator; | |
| use IteratorIterator; | |
| use Traversable; | |
| final class TrimIteratorIterator extends IteratorIterator | |
| { | |
| private $characters; | |
| public function __construct(Traversable $iterator, ?string $characters = " \n\r\t\v\x00") | |
| { | |
| parent::__construct($iterator); | |
| $this->characters = $characters; | |
| } | |
| public function current() | |
| { | |
| return trim(parent::current(), $this->characters); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment