SendContactMethod   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 14
dl 0
loc 58
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 15 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace TgBotApi\BotApiBase\Method;
6
7
use TgBotApi\BotApiBase\Method\Interfaces\SendMethodAliasInterface;
8
use TgBotApi\BotApiBase\Method\Traits\FillFromArrayTrait;
9
use TgBotApi\BotApiBase\Method\Traits\SendToChatVariablesTrait;
10
11
/**
12
 * Class SendContactMethod.
13
 *
14
 * @see https://core.telegram.org/bots/api#sendcontact
15
 */
16
class SendContactMethod implements SendMethodAliasInterface
17
{
18
    use FillFromArrayTrait;
19
    use SendToChatVariablesTrait;
20
21
    /**
22
     * Contact's phone number.
23
     *
24
     * @var string
25
     */
26
    public $phoneNumber;
27
28
    /**
29
     * Contact's first name.
30
     *
31
     * @var string
32
     */
33
    public $firstName;
34
35
    /**
36
     * Optional. Contact's last name.
37
     *
38
     * @var string|null
39
     */
40
    public $lastName;
41
42
    /**
43
     * Optional. Additional data about the contact in the form of a vCard, 0-2048 bytes.
44
     *
45
     * @var string|null
46
     */
47
    public $vcard;
48
49
    /**
50
     * @param int|string $chatId
51
     * @param string     $phoneNumber
52
     * @param string     $firstName
53
     * @param array|null $data
54
     *
55
     * @throws \TgBotApi\BotApiBase\Exception\BadArgumentException
56
     *
57
     * @return SendContactMethod
58
     */
59 2
    public static function create(
60
        $chatId,
61
        string $phoneNumber,
62
        string $firstName,
63
        array $data = null
64
    ): SendContactMethod {
65 2
        $instance = new static();
66 2
        $instance->chatId = $chatId;
67 2
        $instance->phoneNumber = $phoneNumber;
68 2
        $instance->firstName = $firstName;
69 2
        if ($data) {
70 1
            $instance->fill($data);
71
        }
72
73 2
        return $instance;
74
    }
75
}
76