Blame view

backend/components/parsers/ParserHandler.php 668 Bytes
fcd9278e   Mihail   parser csv v1
1
2
  <?php
  namespace app\components\parsers;
1e991822   Mihail   csv parser with e...
3
4
  
  use app\components\parsers\CsvParser;
fcd9278e   Mihail   parser csv v1
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
  
  class ParserHandler {
  
  /** @var string */
      private $filePath;
  
      /** @var string */
      private $extension;
  
      /**
       * @param string $filePath parsing file path
       */
      public function __construct( $filePath )
      {
          $this->filePath = $filePath;
          preg_match( '/\.[^\.]+$/i',$filePath, $resultArray );
          $this->extension = $resultArray[0];
  
          $this->run();
      }
  
9ef73019   Mihail   parser
26
      public function run(){
fcd9278e   Mihail   parser csv v1
27
          if ($this->extension = '.csv'){
1e991822   Mihail   csv parser with e...
28
29
  
              $csvParser = new CsvParser( $this->filePath );
2772f19c   Mihail   parser csv v2
30
              return $csvParser->read();
fcd9278e   Mihail   parser csv v1
31
32
          };
      }
1e991822   Mihail   csv parser with e...
33
  }