BaseChat::sendMessage()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 20
rs 9.9332
cc 1
nc 1
nop 8

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
3
4
namespace Sysbot\Telegram\ExtendedTypes;
5
6
7
use GuzzleHttp\Promise\PromiseInterface;
8
use Sysbot\Telegram\Types\ForceReply;
9
use Sysbot\Telegram\Types\InlineKeyboardMarkup;
10
use Sysbot\Telegram\Types\ReplyKeyboardMarkup;
11
use Sysbot\Telegram\Types\ReplyKeyboardRemove;
12
13
trait BaseChat
14
{
15
16
    use BaseType;
17
18
    public function sendMessage(
19
        string $text,
20
        ?string $parseMode = null,
21
        ?array $entities = null,
22
        ?bool $disableWebPagePreview = null,
23
        ?bool $disableNotification = null,
24
        ?int $replyToMessageId = null,
25
        ?bool $allowSendingWithoutReply = null,
26
        InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply|null $replyMarkup = null
27
    ): PromiseInterface {
28
        return $this->api->sendMessage(
29
            chatId: $this->id,
30
            text: $text,
31
            parseMode: $parseMode,
32
            entities: $entities,
33
            disableWebPagePreview: $disableWebPagePreview,
34
            disableNotification: $disableNotification,
35
            replyToMessageId: $replyToMessageId,
36
            allowSendingWithoutReply: $allowSendingWithoutReply,
37
            replyMarkup: $replyMarkup
38
        );
39
    }
40
41
}