云控蜘蛛工厂 * * 新增云控类型:在 spider/ 下新增类并在此注册 ticket_type => Class */ class SplitScrmSpiderFactory { /** @var array> */ private const MAP = [ 'a2c' => A2cSpider::class, 'haiwang' => HaiwangSpider::class, 'huojian' => HuojianSpider::class, 'xinghe' => XingheSpider::class, 'ss_customer' => SsCustomerSpider::class, // ceo_scrm 等未实现类型:新增 spider 类后在此注册 ]; /** * @return class-string|null */ public static function resolveClass(string $ticketType): ?string { $ticketType = trim($ticketType); return self::MAP[$ticketType] ?? null; } /** * 是否已实现蜘蛛 */ public static function isSupported(string $ticketType): bool { return self::resolveClass($ticketType) !== null; } /** * @return ScrmSpiderInterface|null */ public static function create( string $ticketType, string $pageUrl, string $account = '', string $password = '', string $nodeHost = '' ): ?ScrmSpiderInterface { $class = self::resolveClass($ticketType); if ($class === null) { return null; } $host = $nodeHost !== '' ? $nodeHost : SplitSyncConfigService::getNodeHost(); return new $class($pageUrl, $account, $password, $host); } }