for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace AppBundle\UpdateReceiver;
use Shaygan\TelegramBotApiBundle\TelegramBotApi;
use Shaygan\TelegramBotApiBundle\Type\Update;
use Shaygan\TelegramBotApiBundle\UpdateReceiver\UpdateReceiverInterface;
class UpdateReceiver implements UpdateReceiverInterface
{
private $config;
private $telegramBotApi;
public function __construct(TelegramBotApi $telegramBotApi, $config)
$this->telegramBotApi = $telegramBotApi;
$this->config = $config;
}
public function handleUpdate(Update $update)
$message = json_decode(json_encode($update->message), true);
switch ($message['text']) {
case "/about":
case "/about@{$this->config['bot_name']}":
$text = "I'm a Buktopuha Telegram Bot";
break;
case "/help":
case "/help@{$this->config['bot_name']}":
default :
As per the PSR-2 coding standard, there must not be a space in front of the colon in the default statement.
switch ($expr) { default : //wrong doSomething(); break; } switch ($expr) { default: //right doSomething(); break; }
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.
$text = "Command List:\n";
$text .= "/about - About this bot\n";
$text .= "/help - show this help message\n";
$this->telegramBotApi->sendMessage($message['chat']['id'], $text);
As per the PSR-2 coding standard, there must not be a space in front of the colon in the default statement.
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.