forked from ruskid/yii2-csv-importer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CSVImporter.php
45 lines (36 loc) · 911 Bytes
/
CSVImporter.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
/**
* @copyright Copyright Victor Demin, 2015
* @license https://github.com/ruskid/yii2-csv-importer/LICENSE
* @link https://github.com/ruskid/yii2-csv-importer#README
*/
namespace ruskid\csvimporter;
use ruskid\csvimporter\CSVReader;
use ruskid\csvimporter\ImportInterface;
/**
* Little CSV import helper for Yii2
* @author Victor Demin <[email protected]>
*/
class CSVImporter {
private $_data;
/**
* @param CSVReader $reader
*/
public function setData(CSVReader $reader) {
$this->_data = $reader->readFile();
}
/**
* Will get CSV data
* @return array
*/
public function getData() {
return $this->_data;
}
/**
* Will import csv file using strategy.
* @param ImportInterface $strategy
*/
public function import(ImportInterface $strategy) {
return $strategy->import($this->_data);
}
}