AddContact   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 45
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getContact() 0 3 1
A __construct() 0 4 1
A getSharePhoneNumber() 0 3 1
A typeSerialize() 0 6 1
A fromArray() 0 5 1
1
<?php
2
3
/**
4
 * This phpFile is auto-generated.
5
 */
6
7
declare(strict_types=1);
8
9
namespace PHPTdGram\Schema;
10
11
/**
12
 * Adds a user to the contact list or edits an existing contact by their user identifier.
13
 */
14
class AddContact extends TdFunction
15
{
16
    public const TYPE_NAME = 'addContact';
17
18
    /**
19
     * The contact to add or edit; phone number can be empty and needs to be specified only if known, vCard is ignored.
20
     */
21
    protected Contact $contact;
22
23
    /**
24
     * True, if the new contact needs to be allowed to see current user's phone number. A corresponding rule to userPrivacySettingShowPhoneNumber will be added if needed. Use the field UserFullInfo.need_phone_number_privacy_exception to check whether the current user needs to be asked to share their phone number.
25
     */
26
    protected bool $sharePhoneNumber;
27
28
    public function __construct(Contact $contact, bool $sharePhoneNumber)
29
    {
30
        $this->contact          = $contact;
31
        $this->sharePhoneNumber = $sharePhoneNumber;
32
    }
33
34
    public static function fromArray(array $array): AddContact
35
    {
36
        return new static(
37
            TdSchemaRegistry::fromArray($array['contact']),
38
            $array['share_phone_number'],
39
        );
40
    }
41
42
    public function typeSerialize(): array
43
    {
44
        return [
45
            '@type'              => static::TYPE_NAME,
46
            'contact'            => $this->contact->typeSerialize(),
47
            'share_phone_number' => $this->sharePhoneNumber,
48
        ];
49
    }
50
51
    public function getContact(): Contact
52
    {
53
        return $this->contact;
54
    }
55
56
    public function getSharePhoneNumber(): bool
57
    {
58
        return $this->sharePhoneNumber;
59
    }
60
}
61