28 lines
860 B
PHP
Executable File
28 lines
860 B
PHP
Executable File
<?php
|
|
|
|
namespace Common\Helpers;
|
|
|
|
require_once __DIR__ . '/../../discord/converters/HtmlToDiscordMarkdownConverter.php';
|
|
require_once __DIR__ . '/../../telegram/converters/HtmlToTelegramHtmlConverter.php';
|
|
|
|
use Discord\Converters\HtmlToDiscordMarkdownConverter;
|
|
use Telegram\Converters\HtmlToTelegramHtmlConverter;
|
|
|
|
class ConverterFactory
|
|
{
|
|
public static function create(string $platform): object
|
|
{
|
|
return match ($platform) {
|
|
'discord' => new HtmlToDiscordMarkdownConverter(),
|
|
'telegram' => new HtmlToTelegramHtmlConverter(),
|
|
default => throw new \InvalidArgumentException("Plataforma no soportada: $platform"),
|
|
};
|
|
}
|
|
|
|
public static function convert(string $platform, string $html): string
|
|
{
|
|
$converter = self::create($platform);
|
|
return $converter->convert($html);
|
|
}
|
|
}
|