SendPassportAuthorizationForm::fromArray()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
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
 * Sends a Telegram Passport authorization form, effectively sharing data with the service. This method must be called after getPassportAuthorizationFormAvailableElements if some previously available elements need to be used.
13
 */
14
class SendPassportAuthorizationForm extends TdFunction
15
{
16
    public const TYPE_NAME = 'sendPassportAuthorizationForm';
17
18
    /**
19
     * Authorization form identifier.
20
     */
21
    protected int $autorizationFormId;
22
23
    /**
24
     * Types of Telegram Passport elements chosen by user to complete the authorization form.
25
     *
26
     * @var PassportElementType[]
27
     */
28
    protected array $types;
29
30
    public function __construct(int $autorizationFormId, array $types)
31
    {
32
        $this->autorizationFormId = $autorizationFormId;
33
        $this->types              = $types;
34
    }
35
36
    public static function fromArray(array $array): SendPassportAuthorizationForm
37
    {
38
        return new static(
39
            $array['autorization_form_id'],
40
            array_map(fn ($x) => TdSchemaRegistry::fromArray($x), $array['types']),
41
        );
42
    }
43
44
    public function typeSerialize(): array
45
    {
46
        return [
47
            '@type'                => static::TYPE_NAME,
48
            'autorization_form_id' => $this->autorizationFormId,
49
            array_map(fn ($x)      => $x->typeSerialize(), $this->types),
50
        ];
51
    }
52
53
    public function getAutorizationFormId(): int
54
    {
55
        return $this->autorizationFormId;
56
    }
57
58
    public function getTypes(): array
59
    {
60
        return $this->types;
61
    }
62
}
63