Last active
April 2, 2021 09:44
-
-
Save koyablue/e45b783c9bbdee2bee91937228b023a5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Services\FileImport; | |
use App\Services\FileImport\Importer\DeliveryJoblistFileImporter; | |
use App\Services\FileImport\Importer\OfficeWorkJoblistFileImporter; | |
use App\Services\FileImport\Importer\RestaurantJoblistFileImporter; | |
use App\Services\FileImport\Interface\FileImporterInterface; | |
class ImporterFactory | |
{ | |
private static array $importers = [ | |
OfficeWorkJoblistFileImporter::class, | |
RestaurantJoblistFileImporter::class, | |
DeliveryJoblistFileImporter::class | |
]; | |
/** | |
* createImporter | |
* | |
* @param mixed $fileType | |
* @return FileImporterInterface | |
*/ | |
public static function createImporter(int $fileType): FileImporterInterface | |
{ | |
foreach (self::$importers as $importer) { | |
if ($importer::type() === $fileType) { | |
return new $importer(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment