Conditions | 3 |
Paths | 4 |
Total Lines | 11 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
40 | 3 | public function __construct($token = null, $options = []) |
|
41 | { |
||
42 | 3 | $this->token = $token ?: getenv('TELEGRAM_TOKEN'); |
|
|
|||
43 | 3 | if (!$this->token) { |
|
44 | 1 | throw new TelegramCoreException('Token must be defined'); |
|
45 | } |
||
46 | $baseOptions = [ |
||
47 | 2 | 'base_uri' => sprintf('https://api.telegram.org/bot%s/', $token), |
|
48 | 2 | ]; |
|
49 | 2 | $this->client = new Client(array_merge($baseOptions, $options)); |
|
50 | 2 | } |
|
51 | |||
87 | } |
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: