예제 #1
0
 /**
  * Constructor
  *
  * @param string $argv
  */
 public function __construct($argv)
 {
     // Register connection instance
     Ioc::instance('connection', new Connection());
     set_time_limit(0);
     $allowedTypes = array_keys($this->headerMap);
     $inputDate = $this->checkInputDate($argv[2]);
     if (!$inputDate) {
         throw new \Exception('File date is required. Format: YYYY-MM-DD');
     }
     $this->fileDate = $this->convertFileDate($inputDate);
     $this->fileType = trim(isset($argv[1]) ? $argv[1] : null);
     if (!in_array($this->fileType, $allowedTypes) || !isset($this->filePattern[$this->fileType])) {
         throw new \Exception('Invalid file type: ' . $this->fileType . ' (Allowed types: ' . implode(', ', $allowedTypes) . ')');
     }
     $this->filePath = $this->loadFilePaths($argv);
 }
예제 #2
0
 public function __construct($argv)
 {
     // TODO: deprecated (remove later)
     $this->connection = new Connection();
     // Register connection instance
     Ioc::instance('connection', new Connection());
     $allowedTypes = array_keys($this->docMap);
     if (!isset($argv[1]) || !in_array($argv[1], $allowedTypes)) {
         self::help();
         throw new \Exception('Invalid data type: ' . @$argv[1] . ' (Allowed types: ' . implode(', ', $allowedTypes) . ')');
     }
     $date_format = 'Y-m-d';
     $date = trim(@$argv[2]);
     if (!isset($argv[2]) || !strtotime($date) || date($date_format, strtotime($date)) !== $date) {
         self::help();
         throw new \Exception('Invalid date: ' . $date . ' (Date format must be yyyy-mm-dd)');
     }
     $this->dataType = $argv[1];
     $this->dataDateTime = strtotime($date);
     $this->dataDate = date($date_format, $this->dataDateTime);
 }