<?php

declare(strict_types=1);

namespace Seka\Portal\Modul\Statistiky\Providers;

use Illuminate\Support\ServiceProvider;
use \App\Repositories\PracoviskoRepositoryContract;
use Seka\Portal\Modul\Statistiky\Services\Analyzators\XLSXHeader;
use Seka\Portal\Modul\Statistiky\Services\Import\ImportDataService;
use Seka\Portal\Modul\Statistiky\Repositories\ZaznamRepositoryContract;
use Seka\Portal\Modul\Statistiky\Services\Analyzators\XLSXDataAnalyzator;
use Seka\Portal\Modul\Statistiky\Services\Import\ImportDataServiceContract;
use Seka\Portal\Modul\Statistiky\Services\Analyzators\DataAnalyzatorContract;
use Seka\Portal\Modul\Statistiky\Services\Transformators\XLSXDataTransformator;
use Seka\Portal\Modul\Statistiky\Services\Transformators\DataTransformatorContract;

/**
 * Class ServicesServiceProvider
 *
 * @package Seka\Portal\Modul\Statistiky\Providers
 */
final class ServicesServiceProvider extends ServiceProvider
{
    /**
     * @return void
     */
    public function register(): void
    {
        $this->app->bind(DataAnalyzatorContract::class, function () {
            return new XLSXDataAnalyzator(XLSXHeader::$header);
        });

        $this->app->bind(DataTransformatorContract::class, function ($app) {
            return new XLSXDataTransformator();
        });

        if (! $this->app->environment('testing')) {
            $this->app->bind(ImportDataServiceContract::class, function ($app) {
                return new ImportDataService(
                    $app->make(ZaznamRepositoryContract::class),
                    $app->make(DataAnalyzatorContract::class),
                    $app->make(PracoviskoRepositoryContract::class),
                    $app->make(DataTransformatorContract::class)
                );
            });
        }
    }
}
