Conditions | 3 |
Paths | 4 |
Total Lines | 11 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Tests | 3 |
CRAP Score | 4.679 |
Changes | 2 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
30 | public function __construct($token = null, $options = []) |
||
31 | 1 | { |
|
32 | 1 | $this->token = $token ?: getenv('TELEGRAM_TOKEN'); |
|
|
|||
33 | 1 | if (!$this->token) { |
|
34 | throw new TelegramCoreException('Token must be defined'); |
||
35 | } |
||
36 | $baseOptions = [ |
||
37 | 'base_uri' => sprintf('https://api.telegram.org/bot%s/', $token), |
||
38 | ]; |
||
39 | $this->client = new Client(array_merge($baseOptions, $options)); |
||
40 | } |
||
41 | 1 | ||
65 | } |
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: