Passed
Push — master ( 59a435...62cb7b )
by Nikolay
11:22
created

SendContactMethod::create()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

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