<?php

namespace Openguru\OpenCartFramework\ImageTool;

use Openguru\OpenCartFramework\Container\Container;
use Openguru\OpenCartFramework\Container\ServiceProvider;

class ImageToolServiceProvider extends ServiceProvider
{
    public function register(): void
    {
        $this->container->bind(ImageFactory::class, function (Container $container) {
            $driver = extension_loaded('imagick') ? 'imagick' : 'gd';

            return new ImageFactory(
                $container->getConfigValue('paths.images'),
                $container->getConfigValue('app.shop_base_url'),
                $driver,
                [
                    'cache_path' => $container->getConfigValue('paths.images_cache', 'cache/telecart'),
                ]
            );
        });
    }
}
