Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
lpheller committed Nov 2, 2023
1 parent 500517a commit c9a643a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
11 changes: 3 additions & 8 deletions src/Csv.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public function count()
{
$count = 0;

foreach ($this->processWithGenerator() as $row) {
foreach ($this->processor->process() as $row) {
$count++;
}

Expand All @@ -176,7 +176,7 @@ public function count()
public function get()
{
$data = [];
foreach ($this->processWithGenerator() as $row) {
foreach ($this->processor->process() as $row) {
$data[] = $row;
}

Expand All @@ -190,7 +190,7 @@ public function get()
*/
public function each($callback)
{
foreach ($this->processWithGenerator() as $row) {
foreach ($this->processor->process() as $row) {
$callback($row);
}
}
Expand All @@ -207,9 +207,4 @@ public function toJson()
{
return json_encode($this->get(), JSON_THROW_ON_ERROR);
}

public function processWithGenerator()
{
return $this->processor->process();
}
}
4 changes: 2 additions & 2 deletions src/CsvProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function process()
continue; // Skip rows based on specified row numbers
}

$row = $this->processRow($row);
$row = $this->prepareRow($row);

if ($this->filterCallback instanceof \Closure && ! call_user_func($this->filterCallback, $row)) {
continue; // Skip rows that don't match the filter criteria
Expand All @@ -62,7 +62,7 @@ public function process()
*
* @return array|object
*/
public function processRow(array $row)
public function prepareRow(array $row)
{
$row = $this->skipColumnsByIndex($row);
$row = $this->skipColumnsByHeaderName($row);
Expand Down

0 comments on commit c9a643a

Please sign in to comment.