| Total Complexity | 5 |
| Total Lines | 49 |
| 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 | * @var Contact |
||
| 22 | */ |
||
| 23 | protected Contact $contact; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * 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. |
||
| 27 | * |
||
| 28 | * @var bool |
||
| 29 | */ |
||
| 30 | protected bool $sharePhoneNumber; |
||
| 31 | |||
| 32 | public function __construct(Contact $contact, bool $sharePhoneNumber) |
||
| 33 | { |
||
| 34 | $this->contact = $contact; |
||
| 35 | $this->sharePhoneNumber = $sharePhoneNumber; |
||
| 36 | } |
||
| 37 | |||
| 38 | public static function fromArray(array $array): AddContact |
||
| 39 | { |
||
| 40 | return new static( |
||
| 41 | TdSchemaRegistry::fromArray($array['contact']), |
||
| 42 | $array['share_phone_number'], |
||
| 43 | ); |
||
| 44 | } |
||
| 45 | |||
| 46 | public function typeSerialize(): array |
||
| 47 | { |
||
| 48 | return [ |
||
| 49 | '@type' => static::TYPE_NAME, |
||
| 50 | 'contact' => $this->contact->typeSerialize(), |
||
| 51 | 'share_phone_number' => $this->sharePhoneNumber, |
||
| 52 | ]; |
||
| 53 | } |
||
| 54 | |||
| 55 | public function getContact(): Contact |
||
| 58 | } |
||
| 59 | |||
| 60 | public function getSharePhoneNumber(): bool |
||
| 61 | { |
||
| 65 |