<?php

declare(strict_types=1);

namespace Seka\Portal\Modul\Statistiky\Providers;

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

/**
 * 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)
                );
            });
        }
    }
}
