Sonata\Exporter\Source\CsvSourceIterator::key PHP Method

key() public method

public key ( )
    public function key()
    {
        return $this->position;
    }

Usage Example

 public function testNoHeaders()
 {
     $iterator = new CsvSourceIterator($this->filename, ',', '"', '\\', false);
     $i = 0;
     foreach ($iterator as $value) {
         $this->assertTrue(is_array($value));
         $this->assertEquals(2, count($value));
         $this->assertEquals($i, $iterator->key());
         ++$i;
     }
     $this->assertEquals(4, $i);
 }