* @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\PrestaShop\Adapter\Import\Handler; use PrestaShop\PrestaShop\Core\Import\Exception\NotSupportedImportTypeException; use PrestaShop\PrestaShop\Core\Import\Handler\ImportHandlerFinderInterface; use PrestaShop\PrestaShop\Core\Import\Handler\ImportHandlerInterface; /** * Class ImportHandlerFinder is responsible for finding a proper import handler. */ final class ImportHandlerFinder implements ImportHandlerFinderInterface { /** * @var ImportHandlerInterface[] */ private $importHandlers; /** * @param ImportHandlerInterface[] ...$importHandlers */ public function __construct(ImportHandlerInterface ...$importHandlers) { $this->importHandlers = $importHandlers; } /** * {@inheritdoc} */ public function find($importEntityType) { foreach ($this->importHandlers as $importHandler) { if ($importHandler->supports($importEntityType)) { return $importHandler; } } throw new NotSupportedImportTypeException(); } }