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);
|
||||
}
|
||||
}
|
||||
26
common/helpers/sender_factory.php
Executable file
26
common/helpers/sender_factory.php
Executable file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Common\Helpers;
|
||||
|
||||
require_once __DIR__ . '/../../discord/DiscordSender.php';
|
||||
require_once __DIR__ . '/../../telegram/TelegramSender.php';
|
||||
|
||||
use Discord\DiscordSender;
|
||||
use Telegram\TelegramSender;
|
||||
|
||||
class SenderFactory
|
||||
{
|
||||
public static function create(string $platform): object
|
||||
{
|
||||
return match ($platform) {
|
||||
'discord' => new DiscordSender(),
|
||||
'telegram' => new TelegramSender(),
|
||||
default => throw new \InvalidArgumentException("Plataforma no soportada: $platform"),
|
||||
};
|
||||
}
|
||||
|
||||
public static function getPlatforms(): array
|
||||
{
|
||||
return ['discord', 'telegram'];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user