for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Tleckie\Csv;
use function current;
use function key;
use function next;
use function reset;
/**
* Class Row
*
* @package Tleckie\Csv
* @author Teodoro Leckie Westberg <[email protected]>
*/
class Row implements RowInterface
{
/** @var array */
private array $data;
* Row constructor.
* @param array $data
public function __construct(array $data = [])
$this->data = $data;
}
* @inheritdoc
public function rewind(): void
reset($this->data);
public function current(): string
return current($this->data);
public function key(): int
return key($this->data);
public function next(): bool
return next($this->data);
public function valid(): bool
return key($this->data) !== null;
public function toArray(): array
return $this->data;
public function reverse(): RowInterface
return new Row(array_reverse($this->data));
public function byIndex(mixed $index): mixed
return $this->data[$index] ?? null;
public function hasIndex(mixed $index): bool
return isset($this->data[$index]);
public function removeByIndex(mixed $index): RowInterface
$data = $this->data;
unset($data[$index]);
return new Row($data);
public function removeFirst(): RowInterface
$data = array_slice($this->data, 1, null, true);
public function removeLast(): RowInterface
array_pop($data);
public function count(): int
return count($this->data);