Craft\ImportService::data PHP Method

data() public method

Get CSV data.
public data ( string $file ) : array
$file string
return array
    public function data($file)
    {
        // Open CSV file
        $data = $this->_open($file);
        // Skip first row
        array_shift($data);
        // Return all data
        return $data;
    }

Usage Example

Exemplo n.º 1
0
 /**
  * @covers ::data
  */
 public function testDataShouldReturnDataRows()
 {
     $file = __DIR__ . '/tst_csv.csv';
     $expectedData = array(array('row1value1', 'row1value2', 'row1value3', 'row1value4', 'row1value5'), array('row1value1', 'row2value2', 'row3value3', 'row4value4', 'row5value5'));
     $this->setMockAssetsService($file);
     $service = new ImportService();
     $result = $service->data($file);
     $this->assertSame($expectedData, $result);
 }