MessagePassportDataReceived::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 2
dl 0
loc 6
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 AurimasNiekis\TdLibSchema;
10
11
/**
12
 * Telegram Passport data has been received; for bots only.
13
 */
14
class MessagePassportDataReceived extends MessageContent
15
{
16
    public const TYPE_NAME = 'messagePassportDataReceived';
17
18
    /**
19
     * List of received Telegram Passport elements.
20
     *
21
     * @var EncryptedPassportElement[]
22
     */
23
    protected array $elements;
24
25
    /**
26
     * Encrypted data credentials.
27
     *
28
     * @var EncryptedCredentials
29
     */
30
    protected EncryptedCredentials $credentials;
31
32
    public function __construct(array $elements, EncryptedCredentials $credentials)
33
    {
34
        parent::__construct();
35
36
        $this->elements    = $elements;
37
        $this->credentials = $credentials;
38
    }
39
40
    public static function fromArray(array $array): MessagePassportDataReceived
41
    {
42
        return new static(
43
            array_map(fn ($x) => TdSchemaRegistry::fromArray($x), $array['elements']),
44
            TdSchemaRegistry::fromArray($array['credentials']),
45
        );
46
    }
47
48
    public function typeSerialize(): array
49
    {
50
        return [
51
            '@type'           => static::TYPE_NAME,
52
            array_map(fn ($x) => $x->typeSerialize(), $this->elements),
53
            'credentials'     => $this->credentials->typeSerialize(),
54
        ];
55
    }
56
57
    public function getElements(): array
58
    {
59
        return $this->elements;
60
    }
61
62
    public function getCredentials(): EncryptedCredentials
63
    {
64
        return $this->credentials;
65
    }
66
}
67