<?php
namespace EasyChat\Library\Commerce;

final class CommerceProviderFactory
{
    public static function create($db, string $type, string $prefix, array $settings = array()): ?CommerceContextProviderInterface
    {
        switch (strtolower(trim($type))) {
            case 'opencart':
                return new OpenCartCommerceContextProvider($db, $prefix, $settings);
            case 'wordpress':
            case 'woocommerce':
                return new WooCommerceContextProvider($db, $prefix, $settings);
            case 'webasyst':
            case 'shopscript':
                return new WebasystCommerceContextProvider($db, $prefix, $settings);
            case 'bitrix':
                return new BitrixCommerceContextProvider($db, $prefix, $settings);
            default:
                return null;
        }
    }
}
