CustomEventsHandler::messageNew()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
require __DIR__ . '/../vendor/autoload.php';
3
4
use erjanmx\nambaone\Client;
5
use erjanmx\nambaone\EventsHandler;
6
use erjanmx\nambaone\ClientException;
7
8
/**
9
 * @class
10
 */
11
class CustomEventsHandler extends EventsHandler
12
{
13
    public $events = [
14
        'message/new' => 'messageNew',
15
    ];
16
17
    public function messageNew($data)
18
    {
19
        $this->client->to($data['chat_id'])->setType($data['type'])->setContent($data['content'])->send();
0 ignored issues
show
Bug introduced by
The method to() does not exist on erjanmx\nambaone\Client. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

19
        $this->client->/** @scrutinizer ignore-call */ 
20
                       to($data['chat_id'])->setType($data['type'])->setContent($data['content'])->send();
Loading history...
20
    }
21
}
22
23
$API_KEY = '';
24
try {
25
    $client = new Client($API_KEY, new CustomEventsHandler());
26
27
    $client->handleEvents();
28
} catch (ClientException $e) {
29
    //handle exception
30
}
31