Skip to content

Instantly share code, notes, and snippets.

@evgeniy1204
Created April 24, 2023 06:19
Show Gist options
  • Save evgeniy1204/88ffbd98365ad577df61b82f3b4dc750 to your computer and use it in GitHub Desktop.
Save evgeniy1204/88ffbd98365ad577df61b82f3b4dc750 to your computer and use it in GitHub Desktop.
<?php
namespace Avby\Domain;
class BotEvents
{
public const START = '/start';
public const MY_SERVICES = 'Мои услуги';
public const PAY = 'Оплата';
/**
* @return string[]
*/
public static function getAllSupportedEvents(): array
{
return [
self::START => 'onStart',
self::MY_SERVICES => 'onMyServices',
self::PAY => 'onPay',
];
}
/**
* @param string $event
*
* @return bool
*/
public static function isValid(string $event): bool
{
return array_key_exists($event, self::getAllSupportedEvents());
}
/**
* @param string $event
*
* @return string
*/
public static function getTechnicalEvent(string $event): string
{
if (!self::isValid($event)) {
throw new \LogicException('Invalid event '. $event);
}
return self::getAllSupportedEvents()[$event];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment