<?php

namespace DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\Factory;

use DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\DataProvider\ExportFileTypeDataProvider;
use DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\DataProvider\ExportManagerDataProvider;
use DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\DataProvider\SettingsDataProvider;
use DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\DataProvider\SettingsProvider;
use DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\DataProvider\ExportMapperDataProvider;
use DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\DataProvider\ExportOptionsDataProvider;
use DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\Infrastructure\Service\Dependency\Resolver\Abstraction\DependencyResolverInterface;
use DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\DataProvider\ExportLogicDataProvider;
use RuntimeException;
use DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\DataProvider\AttributeCeneoDataProvider;
use DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\DataProvider\CategoryCeneoDataProvider;
use DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\DataProvider\CategoryNokautDataProvider;
use DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\DataProvider\CeneoExportMapperDataProvider;
use DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\DataProvider\DropshippingDataProvider;
use DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\DataProvider\GmcExportMapperDataProvider;
use DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\DataProvider\HomebookExportMapperDataProvider;
use DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\DataProvider\NokautExportMapperDataProvider;
use DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\DataProvider\UcpSettingsDataProvider;
class DataProviderFactory
{
    /**
     * @var DependencyResolverInterface
     */
    private $resolver;
    public function __construct(DependencyResolverInterface $dependency_resolver)
    {
        $this->resolver = $dependency_resolver;
    }
    public function create_by_class_name(string $class_name, array $arguments = []): DropshippingDataProvider
    {
        $data_providers = $this->get_all_data_providers();
        foreach ($data_providers as $data_provider) {
            if ($class_name === $data_provider) {
                return $this->resolver->resolve($data_provider, $arguments);
            }
        }
        throw new RuntimeException('Error, data provider classname ' . $class_name . ' not found.');
    }
    public function create_by_id(string $id, array $arguments = []): DropshippingDataProvider
    {
        $data_providers = $this->get_all_data_providers();
        foreach ($data_providers as $data_provider) {
            if ($id === $data_provider::get_id()) {
                return $this->resolver->resolve($data_provider, $arguments);
            }
        }
        throw new RuntimeException('Error, data provider id ' . $id . ' not found.');
    }
    private function get_all_data_providers(): array
    {
        return [ExportManagerDataProvider::class, SettingsDataProvider::class, ExportFileTypeDataProvider::class, ExportLogicDataProvider::class, ExportMapperDataProvider::class, ExportOptionsDataProvider::class, SettingsProvider::class, AttributeCeneoDataProvider::class, CategoryCeneoDataProvider::class, CategoryNokautDataProvider::class, CeneoExportMapperDataProvider::class, NokautExportMapperDataProvider::class, HomebookExportMapperDataProvider::class, GmcExportMapperDataProvider::class, UcpSettingsDataProvider::class];
    }
}
