<?php

namespace App\Services\OCR;

use App\Services\OCR\Drivers\AliyunOCRDriver;
use App\Services\OCR\Drivers\ExternalOCRDriver;
use App\Services\OCR\Drivers\BaiduOCRDriver;
use InvalidArgumentException;

class OCRFactory
{
    public static function create(string $driver = null): OCRInterface
    {
        $driver = $driver ?? config('ocr.driver', 'aliyun');

        switch ($driver) {
            case 'aliyun':
                return new AliyunOCRDriver(config('ocr.drivers.aliyun'));
            case 'baidu':
                return new BaiduOCRDriver(config('ocr.drivers.baidu'));
            case 'external':
                return new ExternalOCRDriver(config('ocr.drivers.external'));
            default:
                throw new InvalidArgumentException("Unsupported OCR driver: {$driver}");
        }
    }
}
