Initial commit - Last War messaging system
This commit is contained in:
27
common/helpers/converter_factory.php
Executable file
27
common/helpers/converter_factory.php
Executable file
@@ -0,0 +1,27 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user