Last active
April 2, 2021 08:30
-
-
Save koyablue/2cd8b517c68a0d4cf74daf5a77c30de3 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\Models\Dto\FileImportDto; | |
use App\Services\FileImport\ImporterFactory; | |
use App\Services\FileImport\Interface\FileImporterInterface; | |
class JoblistFileImportContext | |
{ | |
private FileImporterInterface $importer; | |
public function __construct(FileImportDto $fileDto) | |
{ | |
$this->setImporter($fileDto->fileType); | |
} | |
/** | |
* setStrategy | |
* | |
* @param int $fileType | |
* @return void | |
*/ | |
public function setImporter(int $fileType) | |
{ | |
$this->importer = ImporterFactory::createImporter($fileType); | |
} | |
/** | |
* execute | |
* | |
* @param FileImportDto $fileDto | |
* @return void | |
*/ | |
public function execute(FileImportDto $fileDto) | |
{ | |
$fileData = $this->importer->readData($fileDto); | |
$this->importer->storeData($fileData); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment