Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding ResultSet::createFromTabularDataReader #381

Merged
merged 1 commit into from
Feb 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ All Notable changes to `Csv` will be documented in this file
- `League\Csv\Statement` can now also process `League\Csv\ResultSet` instances.
- `League\Csv\TabularDataReader` interface to represent how to read tabular data
- `League\Csv\ResultSet::getRecords` has an optional `$header` second argument to make the method works like `League\Csv\Reader::getRecords`
- `League\Csv\ResultSet::createFromReader` create a new instance from `League\Csv\Reader`
- `League\Csv\ResultSet::createFromTabularDataReader` create a new instance from `League\Csv\TabularDataReader` implementing class.

### Deprecated

Expand Down
6 changes: 3 additions & 3 deletions src/Reader.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,23 +199,23 @@ protected function removeBOM(array $record, int $bom_length, string $enclosure):
*/
public function fetchColumn($index = 0): Iterator
{
return ResultSet::createFromReader($this)->fetchColumn($index);
return ResultSet::createFromTabularDataReader($this)->fetchColumn($index);
}

/**
* {@inheritdoc}
*/
public function fetchOne(int $nth_record = 0): array
{
return ResultSet::createFromReader($this)->fetchOne($nth_record);
return ResultSet::createFromTabularDataReader($this)->fetchOne($nth_record);
}

/**
* {@inheritdoc}
*/
public function fetchPairs($offset_index = 0, $value_index = 1): Iterator
{
return ResultSet::createFromReader($this)->fetchPairs($offset_index, $value_index);
return ResultSet::createFromTabularDataReader($this)->fetchPairs($offset_index, $value_index);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/ResultSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function __destruct()
/**
* Returns a new instance from a League\Csv\Reader object.
*/
public static function createFromReader(Reader $reader): self
public static function createFromTabularDataReader(Reader $reader): self
{
return new self($reader->getRecords(), $reader->getHeader());
}
Expand Down