Eccube\Service\CsvImportService::count PHP Method

count() public method

public count ( )
    public function count()
    {
        if (null === $this->count) {
            $position = $this->key();
            $this->count = iterator_count($this);
            $this->seek($position);
        }
        return $this->count;
    }

Usage Example

 public function testCountDoesNotMoveFilePointer()
 {
     $file = new \SplFileObject(__DIR__ . '/../../../Fixtures/data_column_headers.csv');
     $CsvImportService = new CsvImportService($file);
     $CsvImportService->setHeaderRowNumber(0);
     $key_before_count = $CsvImportService->key();
     $CsvImportService->count();
     $key_after_count = $CsvImportService->key();
     $this->assertEquals($key_after_count, $key_before_count);
 }