InputContactMessageContentType::create()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

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