Passed
Push — 994-remove_service_message_sys... ( 049589...421d12 )
by Armando
01:58
created

GenericmessageCommand::executeDeprecatedSystemCommand()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 40
Code Lines 26

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 0
Metric Value
cc 4
eloc 26
nc 4
nop 0
dl 0
loc 40
ccs 0
cts 26
cp 0
crap 20
rs 9.504
c 0
b 0
f 0
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\Commands\SystemCommands;
12
13
use Longman\TelegramBot\Commands\SystemCommand;
14
use Longman\TelegramBot\Entities\ServerResponse;
15
use Longman\TelegramBot\Exception\TelegramException;
16
use Longman\TelegramBot\Request;
17
18
/**
19
 * Generic message command
20
 */
21
class GenericmessageCommand extends SystemCommand
22
{
23
    /**
24
     * @var string
25
     */
26
    protected $name = 'genericmessage';
27
28
    /**
29
     * @var string
30
     */
31
    protected $description = 'Handle generic message';
32
33
    /**
34
     * @var string
35
     */
36
    protected $version = '1.2.0';
37
38
    /**
39
     * @var bool
40
     */
41
    protected $need_mysql = true;
42
43
    /**
44
     * Execution if MySQL is required but not available
45
     *
46
     * @return ServerResponse
47
     * @throws TelegramException
48
     */
49
    public function executeNoDb()
50
    {
51
        // Try to execute any deprecated system commands.
52
        if (self::$execute_deprecated && $deprecated_system_command_response = $this->executeDeprecatedSystemCommand()) {
53
            return $deprecated_system_command_response;
54
        }
55
56
        return Request::emptyResponse();
57
    }
58
59
    /**
60
     * Execute command
61
     *
62
     * @return ServerResponse
63
     * @throws TelegramException
64
     */
65
    public function execute()
66
    {
67
        // Try to continue any active conversation.
68
        if ($active_conversation_response = $this->executeActiveConversation()) {
69
            return $active_conversation_response;
70
        }
71
72
        // Try to execute any deprecated system commands.
73
        if (self::$execute_deprecated && $deprecated_system_command_response = $this->executeDeprecatedSystemCommand()) {
74
            return $deprecated_system_command_response;
75
        }
76
77
        return Request::emptyResponse();
78
    }
79
}
80