SendContactMethod::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2.0185

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 7
ccs 5
cts 6
cp 0.8333
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 4
crap 2.0185
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Greenplugin\TelegramBot\Method;
6
7
use Greenplugin\TelegramBot\Method\Traits\FillFromArrayTrait;
8
use Greenplugin\TelegramBot\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
     * SendContactMethod constructor.
50
     *
51
     * @param int|string $chatId
52
     * @param string     $phoneNumber
53
     * @param string     $firstName
54
     * @param array|null $data
55
     *
56
     * @throws \Greenplugin\TelegramBot\Exception\BadArgumentException
57
     */
58 1
    public function __construct($chatId, string $phoneNumber, string $firstName, array $data = null)
59
    {
60 1
        $this->chatId = $chatId;
61 1
        $this->phoneNumber = $phoneNumber;
62 1
        $this->$firstName = $firstName;
63 1
        if ($data) {
64
            $this->fill($data);
65
        }
66 1
    }
67
}
68