for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Created by PhpStorm.
* User: akeinhell
* Date: 22.06.16
* Time: 12:03
*/
namespace Telegram;
use GuzzleHttp\Client;
use Telegram\Actions\Message;
use Telegram\Exceptions\TelegramCoreException;
* Class Bot
* @package Telegram
* @method static Message message
class Bot
{
* Bot constructor.
* @param null|string $token
* @param array $options
* @throws TelegramCoreException
public function __construct($token = null, $options = [])
$this->token = $token ?: getenv('TELEGRAM_TOKEN');
token
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
class MyClass { } $x = new MyClass(); $x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:
class MyClass { public $foo; } $x = new MyClass(); $x->foo = true;
if (!$this->token) {
throw new TelegramCoreException('Token must be defined');
}
$baseOptions = [
'base_uri' => sprintf('https://api.telegram.org/bot%s/', $token),
];
$this->client = new Client(array_merge($baseOptions, $options));
client
public static function __callStatic($name, $arguments)
$arguments
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.
$class = '\\Telegram\\Actions\\' . ucfirst($name);
if (!class_exists($class)) {
throw new TelegramCoreException('Action ' . $name . ' not exists');
return new $class;
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: