PluginProbe ʕ •ᴥ•ʔ
FAPI Member / trunk
FAPI Member vtrunk
2.2.33 2.2.32 trunk 1.9.47 2.1.18 2.2.24 2.2.25 2.2.26 2.2.28 2.2.29 2.2.30 2.2.31
fapi-member / libs / nette / utils / src / Iterators / Mapper.php
fapi-member / libs / nette / utils / src / Iterators Last commit date
CachingIterator.php 2 years ago Mapper.php 2 years ago
Mapper.php
28 lines
1 <?php
2
3 /**
4 * This file is part of the Nette Framework (https://nette.org)
5 * Copyright (c) 2004 David Grudl (https://davidgrudl.com)
6 */
7 declare (strict_types=1);
8 namespace FapiMember\Library\Nette\Iterators;
9
10 /**
11 * Applies the callback to the elements of the inner iterator.
12 */
13 class Mapper extends \IteratorIterator
14 {
15 /** @var callable */
16 private $callback;
17 public function __construct(\Traversable $iterator, callable $callback)
18 {
19 parent::__construct($iterator);
20 $this->callback = $callback;
21 }
22 #[\ReturnTypeWillChange]
23 public function current()
24 {
25 return ($this->callback)(parent::current(), parent::key());
26 }
27 }
28