Skip to content
This repository has been archived by the owner on May 26, 2022. It is now read-only.

Add dedicated RowIteratorInterface and SheetIteratorInterface #839

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Spout/Reader/CSV/RowIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
use Box\Spout\Common\Manager\OptionsManagerInterface;
use Box\Spout\Reader\Common\Entity\Options;
use Box\Spout\Reader\CSV\Creator\InternalEntityFactory;
use Box\Spout\Reader\IteratorInterface;
use Box\Spout\Reader\RowIteratorInterface;

/**
* Class RowIterator
* Iterate over CSV rows.
*/
class RowIterator implements IteratorInterface
class RowIterator implements RowIteratorInterface
{
/**
* Value passed to fgetcsv. 0 means "unlimited" (slightly slower but accomodates for very long lines).
Expand Down
4 changes: 2 additions & 2 deletions src/Spout/Reader/CSV/SheetIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

namespace Box\Spout\Reader\CSV;

use Box\Spout\Reader\IteratorInterface;
use Box\Spout\Reader\SheetIteratorInterface;

/**
* Class SheetIterator
* Iterate over CSV unique "sheet".
*/
class SheetIterator implements IteratorInterface
class SheetIterator implements SheetIteratorInterface
{
/** @var \Box\Spout\Reader\CSV\Sheet The CSV unique "sheet" */
protected $sheet;
Expand Down
5 changes: 3 additions & 2 deletions src/Spout/Reader/ReaderAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Box\Spout\Common\Manager\OptionsManagerInterface;
use Box\Spout\Reader\Common\Creator\InternalEntityFactoryInterface;
use Box\Spout\Reader\Common\Entity\Options;
use Box\Spout\Reader\CSV\SheetIterator;
use Box\Spout\Reader\Exception\ReaderNotOpenedException;

/**
Expand Down Expand Up @@ -46,7 +47,7 @@ abstract protected function openReader($filePath);
/**
* Returns an iterator to iterate over sheets.
*
* @return IteratorInterface To iterate over sheets
* @return SheetIteratorInterface To iterate over sheets
*/
abstract protected function getConcreteSheetIterator();

Expand Down Expand Up @@ -211,7 +212,7 @@ protected function isPhpStream($filePath)
* Returns an iterator to iterate over sheets.
*
* @throws \Box\Spout\Reader\Exception\ReaderNotOpenedException If called before opening the reader
* @return \Iterator To iterate over sheets
* @return SheetIteratorInterface To iterate over sheets
*/
public function getSheetIterator()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Spout/Reader/ReaderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function open($filePath);
* Returns an iterator to iterate over sheets.
*
* @throws \Box\Spout\Reader\Exception\ReaderNotOpenedException If called before opening the reader
* @return \Iterator To iterate over sheets
* @return SheetIteratorInterface To iterate over sheets
*/
public function getSheetIterator();

Expand Down
22 changes: 22 additions & 0 deletions src/Spout/Reader/RowIteratorInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types=1);

namespace Box\Spout\Reader;

use Box\Spout\Common\Entity\Row;

interface RowIteratorInterface extends IteratorInterface
{
/**
* Cleans up what was created to iterate over the object.
*
* @return void
*/
public function end();

/**
* @return Row|null
*/
public function current();
}
23 changes: 23 additions & 0 deletions src/Spout/Reader/SheetIteratorInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

namespace Box\Spout\Reader;

/**
* Interface IteratorInterface
*/
interface SheetIteratorInterface extends IteratorInterface
{
/**
* Cleans up what was created to iterate over the object.
*
* @return void
*/
public function end();

/**
* @return SheetInterface|null
*/
public function current();
}