Total Complexity | 5 |
Total Lines | 45 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
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 |
||
54 | } |
||
55 | |||
56 | public function getSharePhoneNumber(): bool |
||
59 | } |
||
60 | } |
||
61 |