Completed
Push — feature/refactor-app-design ( d959a3 )
by Avtandil
03:51
created

Kernel   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 88.89%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 4
dl 0
loc 43
ccs 8
cts 9
cp 0.8889
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A handle() 0 12 2
1
<?php
2
/**
3
 * This file is part of the TelegramBot package.
4
 *
5
 * (c) Avtandil Kikabidze aka LONGMAN <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Longman\TelegramBot\Http;
12
13
use Longman\TelegramBot\Entities\Update;
14
use Longman\TelegramBot\Telegram;
15
16
class Kernel
17
{
18
    /**
19
     * The application implementation.
20
     *
21
     * @var \Longman\TelegramBot\Telegram
22
     */
23
    protected $app;
24
25
    /**
26
     * Create a new HTTP kernel instance.
27
     *
28
     * @param  \Longman\TelegramBot\Telegram $app
29
     *
30
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
31
     */
32 1
    public function __construct(Telegram $app)
33
    {
34 1
        $this->app = $app;
35 1
    }
36
37
    /**
38
     * Handle an incoming HTTP request.
39
     *
40
     * @param  \Longman\TelegramBot\Request2 $request
41
     *
42
     * @return \Longman\TelegramBot\Response
43
     *
44
     * @throws \Longman\TelegramBot\Exception\TelegramException
45
     */
46 1
    public function handle(Request $request)
47
    {
48 1
        $params = $request->json();
49
50 1
        $update = new Update($params->all(), $this->app->getBotUsername());
51
52 1
        if ($response = $this->app->processUpdate($update)) {
53 1
            return $response->isOk();
54
        }
55
56
        return $response;
57
    }
58
}
59