PluginProbe
Packeta / 1.4
Packeta v1.4
2.3.2 2.3.1 trunk 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.3.0 1.3.1 1.3.2 1.4 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 All 56 releases
packeta / packetery_vendor / nette / utils / src / Iterators / Mapper.php

Mapper.php in Packeta 1.4, at packetery_vendor/nette/utils/src/Iterators/Mapper.php

35 lines 612 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * This file is part of the PacketeryNette Framework (https://nette.org)
5 * Copyright (c) 2004 David Grudl (https://davidgrudl.com)
6 */
7
8 declare(strict_types=1);
9
10 namespace PacketeryNette\Iterators;
11
12
13
14 /**
15 * Applies the callback to the elements of the inner iterator.
16 */
17 class Mapper extends \IteratorIterator
18 {
19 /** @var callable */
20 private $callback;
21
22
23 public function __construct(\Traversable $iterator, callable $callback)
24 {
25 parent::__construct($iterator);
26 $this->callback = $callback;
27 }
28
29
30 public function current()
31 {
32 return ($this->callback)(parent::current(), parent::key());
33 }
34 }
35