Commit inicial con archivos existentes
This commit is contained in:
57
common/helpers/converter_factory.php
Executable file
57
common/helpers/converter_factory.php
Executable file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/**
|
||||
* Factory para crear Converters según la plataforma
|
||||
*
|
||||
* Este factory simplifica la creación de converters HTML para diferentes plataformas
|
||||
* usando la nueva estructura de directorios.
|
||||
*
|
||||
* Ubicación: /common/helpers/converter_factory.php
|
||||
* Fecha de creación: 2025-11-25
|
||||
*/
|
||||
|
||||
class ConverterFactory {
|
||||
|
||||
/**
|
||||
* Crea un converter para la plataforma especificada
|
||||
*
|
||||
* @param string $platform 'telegram' o 'discord'
|
||||
* @return HtmlToTelegramHtmlConverter|HtmlToDiscordMarkdownConverter
|
||||
* @throws Exception Si la plataforma no es soportada
|
||||
*/
|
||||
public static function create($platform) {
|
||||
switch(strtolower($platform)) {
|
||||
case 'telegram':
|
||||
require_once __DIR__ . '/../../telegram/converters/HtmlToTelegramHtmlConverter.php';
|
||||
return new HtmlToTelegramHtmlConverter();
|
||||
|
||||
case 'discord':
|
||||
require_once __DIR__ . '/../../discord/converters/HtmlToDiscordMarkdownConverter.php';
|
||||
return new HtmlToDiscordMarkdownConverter();
|
||||
|
||||
default:
|
||||
throw new Exception("Plataforma no soportada: $platform. Use 'telegram' o 'discord'");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convierte HTML a formato específico de plataforma
|
||||
*
|
||||
* @param string $html Contenido HTML a convertir
|
||||
* @param string $platform Plataforma destino
|
||||
* @return string Contenido convertido
|
||||
*/
|
||||
public static function convert($html, $platform) {
|
||||
$converter = self::create($platform);
|
||||
return $converter->convert($html);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifica si una plataforma es soportada
|
||||
*
|
||||
* @param string $platform
|
||||
* @return bool
|
||||
*/
|
||||
public static function isSupported($platform) {
|
||||
return in_array(strtolower($platform), ['telegram', 'discord']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user