Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 148 | Details | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 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
 
8
declare(strict_types=1);
9
 
10
namespace Nette\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
 
399 lars 30
	public function current(): mixed
148 lars 31
	{
32
		return ($this->callback)(parent::current(), parent::key());
33
	}
34
}