Completed
Push — master ( a95f7d...eaa6fe )
by Danilo
02:55
created

Bot::__destruct()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 0
cts 6
cp 0
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 5
nc 4
nop 0
crap 12
1
<?php
2
3
/*
4
 * This file is part of the PhpBotFramework.
5
 *
6
 * PhpBotFramework is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU Lesser General Public License as
8
 * published by the Free Software Foundation, version 3.
9
 *
10
 * PhpBotFramework is distributed in the hope that it will be useful, but
11
 * WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
 * Lesser General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU Lesser General Public License
16
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
 */
18
19
namespace PhpBotFramework;
20
21
use PhpBotFramework\Exceptions\BotException;
22
23
// Use localized inline keyboard: this means you can display it in various languages.
24
use PhpBotFramework\Localization\Button;
25
26
use PhpBotFramework\Utilities\BotState;
27
28
use PhpBotFramework\Database\Database;
29
30
use PhpBotFramework\Database\Getter;
31
use PhpBotFramework\Database\LongPolling;
32
33
use PhpBotFramework\Localization\Localization;
34
35
/**
36
 * \class Bot Bot class that contains all modules.
37
 */
38
class Bot extends BasicBot
39
{
40
    use Getter,
41
        LongPolling;
42
43
    /**
44
     * \addtogroup Bot Bot
45
     * \brief Properties and methods to handle your Telegrams bot.
46
     * \details Here're listed all the properties and methods that offers facilities for bot's basic features.
47
     * @{
48
     */
49
50
    /** \brief Store the inline keyboard. */
51
    public $keyboard;
52
53
    /** \brief Database handler object. */
54
    public $database;
55
56
    /** \brief Redis connection. */
57
    public $redis;
58
59
    /** \brief Localization handler object. */
60
    public $local;
61
62
    /**
63
     * \brief Construct an empty bot.
64
     * \details Construct a complete Telegram bot which can use localization, database and more other.
65
     *
66
     * @param string $token Bot token, you can request one through **BotFather** on Telegram.
67
     */
68
    public function __construct(string $token)
69
    {
70
        parent::__construct($token);
71
72
        $this->_message_commands = [];
0 ignored issues
show
Bug introduced by
The property _message_commands does not seem to exist. Did you mean _commands?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
73
        $this->_callback_commands = [];
0 ignored issues
show
Bug introduced by
The property _callback_commands does not seem to exist. Did you mean _commands?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
74
75
        $this->keyboard = new Button($this);
76
        $this->status = new BotState($this);
0 ignored issues
show
Bug introduced by
The property status does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
77
        $this->local = new Localization($this);
78
        $this->database = new Database($this);
79
    }
80
81
    /** @} */
82
}
83