AbstractCsv.php
4 days ago
ByteSequence.php
4 days ago
CannotInsertRecord.php
4 days ago
CharsetConverter.php
4 days ago
ColumnConsistency.php
4 days ago
EncloseField.php
4 days ago
EscapeFormula.php
4 days ago
Exception.php
9 months ago
HTMLConverter.php
4 days ago
Info.php
4 days ago
InvalidArgument.php
9 months ago
MapIterator.php
4 days ago
RFC4180Field.php
4 days ago
Reader.php
4 days ago
ResultSet.php
4 days ago
Statement.php
4 days ago
Stream.php
4 days ago
SyntaxError.php
4 days ago
TabularDataReader.php
4 days ago
UnableToProcessCsv.php
9 months ago
UnavailableFeature.php
9 months ago
UnavailableStream.php
9 months ago
Writer.php
4 days ago
XMLConverter.php
4 days ago
functions.php
9 months ago
functions_include.php
9 months ago
MapIterator.php
40 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * League.Csv (https://csv.thephpleague.com) |
| 5 | * |
| 6 | * (c) Ignace Nyamagana Butera <nyamsprod@gmail.com> |
| 7 | * |
| 8 | * For the full copyright and license information, please view the LICENSE |
| 9 | * file that was distributed with this source code. |
| 10 | */ |
| 11 | declare (strict_types=1); |
| 12 | namespace IAWPSCOPED\League\Csv; |
| 13 | |
| 14 | use IteratorIterator; |
| 15 | use ReturnTypeWillChange; |
| 16 | use Traversable; |
| 17 | /** |
| 18 | * Map value from an iterator before yielding. |
| 19 | * |
| 20 | * @internal used internally to modify CSV content |
| 21 | */ |
| 22 | final class MapIterator extends IteratorIterator |
| 23 | { |
| 24 | /** @var callable The callback to apply on all InnerIterator current value. */ |
| 25 | private $callable; |
| 26 | public function __construct(Traversable $iterator, callable $callable) |
| 27 | { |
| 28 | parent::__construct($iterator); |
| 29 | $this->callable = $callable; |
| 30 | } |
| 31 | /** |
| 32 | * @return mixed The value of the current element. |
| 33 | */ |
| 34 | #[ReturnTypeWillChange] |
| 35 | public function current() |
| 36 | { |
| 37 | return ($this->callable)(parent::current(), parent::key()); |
| 38 | } |
| 39 | } |
| 40 |