/** * @param DriverInterface $driver * @param $type * @param $extension * @param Workbook $workbook * * @throws DriverNotFoundException * @throws ExportFailedException * @return Writer */ public static function create(DriverInterface $driver, $type, $extension, Workbook $workbook) { // Protected export if ($workbook->getSheetCount() < 1) { throw new ExportFailedException('No sheets are added to your Excel file. Make sure you do so, before attempting to export'); } $class = self::getClassByDriverAndType($driver, $type); if (class_exists($class)) { return new $class($type, $extension, $workbook); } // Default writer $class = self::getClassByDriver($driver); if (class_exists($class)) { return new $class($type, $extension, $workbook); } throw new DriverNotFoundException("Writer driver [{$driver->getName()}] was not found"); }