filePath = $filePath; preg_match( '/\.[^\.]+$/i',$filePath, $resultArray ); $this->extension = $resultArray[0]; $this->run(); } private function run(){ if ($this->extension = '.csv'){ $csvParser = new Reader( $this->filePath ); return $csvParser->read(); }; } }