Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
CSVFile.php
1 <?php
2 /**
3  * Created by JetBrains PhpStorm.
4  * User: Andrey
5  * Date: 4/9/13
6  * Time: 12:54 PM
7  * To change this template use File | Settings | File Templates.
8  */
9 
10 class CSVFile extends SplFileObject
11 {
12  private $keys;
13 
14  public function __construct($file)
15  {
16  parent::__construct($file);
17  $this->setFlags(SplFileObject::READ_CSV);
18  }
19 
20  public function rewind()
21  {
22  parent::rewind();
23  $this->keys = parent::current();
24  parent::next();
25  }
26 
27  public function current()
28  {
29  $current = parent::current();
30  if(empty($current[0])){
31  return false;
32  }
33 
34  return array_combine($this->keys, $current);
35  }
36 
37  public function getKeys()
38  {
39  return $this->keys;
40  }
41 }