| Conditions | 4 |
| Paths | 5 |
| Total Lines | 34 |
| Code Lines | 23 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 13 | public function send() |
||
| 14 | { |
||
| 15 | if (!$this->check()) { |
||
| 16 | return; |
||
| 17 | } |
||
| 18 | |||
| 19 | //https://api.telegram.org/{$this->config['token']}/getUpdates |
||
| 20 | $data = $this->data; |
||
| 21 | |||
| 22 | $text = sprintf( |
||
| 23 | '[%s] <b>%s</b>%s[%s] <b>%s</b>%sin <code>%s</code> line %s%s', |
||
| 24 | urlencode($data['method']), |
||
| 25 | urlencode($data['fullUrl']), |
||
| 26 | urlencode("\n \n"), |
||
| 27 | urlencode($data['class']), |
||
| 28 | urlencode($data['exception']), |
||
| 29 | urlencode("\n"), |
||
| 30 | urlencode($data['file']), |
||
| 31 | $data['line'], |
||
| 32 | urlencode("\n \n") |
||
| 33 | ); |
||
| 34 | |||
| 35 | $biggestNumberLength = strlen(max(array_keys($data['file_lines']))); |
||
| 36 | foreach ($data['file_lines'] as $num => $line) { |
||
| 37 | $num = str_pad($num, $biggestNumberLength, ' ', STR_PAD_LEFT); |
||
| 38 | $num = '<code>'. $num .'</code>'; |
||
| 39 | $text .= urlencode($num .'|<code>'. htmlentities($line) .'</code>'); |
||
| 40 | } |
||
| 41 | |||
| 42 | foreach ($this->config['chats'] as $idUser) { |
||
| 43 | $url = 'https://api.telegram.org/'. $this->config['token'] .'/sendMessage?disable_web_page_preview=true&chat_id='. $idUser |
||
| 44 | . '&parse_mode=HTML&text='; |
||
| 45 | |||
| 46 | @file_get_contents($url . $text); |
||
|
|
|||
| 47 | } |
||
| 51 |
If you suppress an error, we recommend checking for the error condition explicitly: