Polyfill
10 months ago
AbstractCsv.php
10 months ago
ByteSequence.php
10 months ago
CannotInsertRecord.php
10 months ago
CharsetConverter.php
10 months ago
ColumnConsistency.php
10 months ago
EncloseField.php
10 months ago
EscapeFormula.php
10 months ago
Exception.php
10 months ago
HTMLConverter.php
10 months ago
Info.php
10 months ago
InvalidArgument.php
10 months ago
MapIterator.php
10 months ago
RFC4180Field.php
10 months ago
Reader.php
10 months ago
ResultSet.php
10 months ago
Statement.php
10 months ago
Stream.php
10 months ago
SyntaxError.php
10 months ago
TabularDataReader.php
10 months ago
UnableToProcessCsv.php
10 months ago
UnavailableFeature.php
10 months ago
UnavailableStream.php
10 months ago
Writer.php
10 months ago
XMLConverter.php
10 months ago
functions.php
10 months ago
functions_include.php
10 months ago
MapIterator.php
47 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 | /** |
| 25 | * The callback to apply on all InnerIterator current value. |
| 26 | * |
| 27 | * @var callable |
| 28 | */ |
| 29 | private $callable; |
| 30 | /** |
| 31 | * New instance. |
| 32 | */ |
| 33 | public function __construct(Traversable $iterator, callable $callable) |
| 34 | { |
| 35 | parent::__construct($iterator); |
| 36 | $this->callable = $callable; |
| 37 | } |
| 38 | /** |
| 39 | * @return mixed The value of the current element. |
| 40 | */ |
| 41 | #[ReturnTypeWillChange] |
| 42 | public function current() |
| 43 | { |
| 44 | return ($this->callable)(parent::current(), parent::key()); |
| 45 | } |
| 46 | } |
| 47 |