Skip to content

Commit

Permalink
Renamed MappedIterato to Mapped
Browse files Browse the repository at this point in the history
  • Loading branch information
klapuch committed Nov 11, 2017
1 parent 269d9a4 commit d6b21d3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Core/MappedIterator.php → Core/Mapped.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* array_map for iterator
*/
final class MappedIterator extends \IteratorIterator {
final class Mapped extends \IteratorIterator {
private $callback;

public function __construct(\Traversable $iterator, callable $callback) {
Expand All @@ -19,4 +19,4 @@ public function __construct(\Traversable $iterator, callable $callback) {
public function current() {
return call_user_func($this->callback, parent::current());
}
}
}
10 changes: 5 additions & 5 deletions Tests/Unit/MappedIterator.phpt → Tests/Unit/Mapped.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ use Tester\Assert;

require __DIR__ . '/../bootstrap.php';

final class MappedIterator extends Tester\TestCase {
final class Mapped extends Tester\TestCase {
public function testAnonymousCallbackFunction() {
$iterator = new \ArrayIterator(['a', 'bb', 'ccc']);
Assert::same(
['aX', 'bbX', 'cccX'],
iterator_to_array(
new Iterator\MappedIterator(
new Iterator\Mapped(
$iterator,
function(string $value): string {
return $value . 'X';
Expand All @@ -37,18 +37,18 @@ final class MappedIterator extends Tester\TestCase {
};
Assert::same(
['aX', 'bbX', 'cccX'],
iterator_to_array(new Iterator\MappedIterator($iterator, [$object, 'map']))
iterator_to_array(new Iterator\Mapped($iterator, [$object, 'map']))
);
}

public function testStringCallback() {
$iterator = new \ArrayIterator(['a', 'bb', 'ccc']);
Assert::same(
['A', 'BB', 'CCC'],
iterator_to_array(new Iterator\MappedIterator($iterator, 'strtoupper'))
iterator_to_array(new Iterator\Mapped($iterator, 'strtoupper'))
);
}
}


(new MappedIterator())->run();
(new Mapped())->run();

0 comments on commit d6b21d3

Please sign in to comment.