Completed
Push — master ( 81f69c...9be858 )
by Freek
02:24
created

Telegram   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 36
rs 10
wmc 2
lcom 1
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A send() 0 10 1
1
<?php
2
3
namespace Spatie\Backup\Notifications\Senders;
4
5
use Illuminate\Contracts\Config\Repository;
6
use Telegram\Bot\Api;
7
use Spatie\Backup\Notifications\BaseSender;
8
9
class Telegram extends BaseSender
10
{
11
    /** @var \Telegram\Bot\Api */
12
    protected $api;
13
14
    /** @var array */
15
    protected $config;
16
17
    /** @var string */
18
    protected $chat_id;
19
20
    /**
21
     * @param \Telegram\Bot\Api $api
22
     * @param Repository        $config
23
     */
24
    public function __construct(Api $api, Repository $config)
25
    {
26
        $this->config = $config->get('laravel-backup.notifications.telegram');
0 ignored issues
show
Documentation Bug introduced by
It seems like $config->get('laravel-ba...otifications.telegram') of type * is incompatible with the declared type array of property $config.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
27
28
        $api->setAccessToken($this->config['bot_token']);
29
        $this->chat_id = $this->config['chat_id'];
30
31
        $this->api = $api;
32
    }
33
34
    public function send()
35
    {
36
        $params = [
37
           'chat_id' => $this->chat_id,
38
           'text' => $this->message,
39
           'disable_web_page_preview' => true,
40
        ];
41
42
        $this->api->sendMessage($params);
43
    }
44
}
45