filePath = $filePath; $this->options = $options; try { $this->fileObject = new \SplFileObject( $this->filePath , 'r' );; } catch (\ErrorException $e) { Yii::warning("Ошибка открытия файла {$this->filePath}"); } //preg_match( '/\.[^\.]+$/i',$filePath, $resultArray ); $this->extension = $this->fileObject->getExtension(); } public function run(){ if ($this->extension = 'csv'){ $csvParser = Yii::createObject([ 'class' => 'backend\components\parsers\CustomCsvParser', 'file' => $this->fileObject, 'auto_detect_first_line' => true, ]); $csvParser->setup(); return $csvParser->read(); }; } }