Created
April 24, 2023 06:19
-
-
Save evgeniy1204/88ffbd98365ad577df61b82f3b4dc750 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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