Skip to content

Instantly share code, notes, and snippets.

@coisa
Last active June 11, 2022 20:35
Show Gist options
  • Select an option

  • Save coisa/a981af1fd8ddd58589ed12189409698e to your computer and use it in GitHub Desktop.

Select an option

Save coisa/a981af1fd8ddd58589ed12189409698e to your computer and use it in GitHub Desktop.
<?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