PassportElementError::getMessage()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
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
 * Contains the description of an error in a Telegram Passport element.
13
 */
14
class PassportElementError extends TdObject
15
{
16
    public const TYPE_NAME = 'passportElementError';
17
18
    /**
19
     * Type of the Telegram Passport element which has the error.
20
     *
21
     * @var PassportElementType
22
     */
23
    protected PassportElementType $type;
24
25
    /**
26
     * Error message.
27
     *
28
     * @var string
29
     */
30
    protected string $message;
31
32
    /**
33
     * Error source.
34
     *
35
     * @var PassportElementErrorSource
36
     */
37
    protected PassportElementErrorSource $source;
38
39
    public function __construct(PassportElementType $type, string $message, PassportElementErrorSource $source)
40
    {
41
        $this->type    = $type;
42
        $this->message = $message;
43
        $this->source  = $source;
44
    }
45
46
    public static function fromArray(array $array): PassportElementError
47
    {
48
        return new static(
49
            TdSchemaRegistry::fromArray($array['type']),
50
            $array['message'],
51
            TdSchemaRegistry::fromArray($array['source']),
52
        );
53
    }
54
55
    public function typeSerialize(): array
56
    {
57
        return [
58
            '@type'   => static::TYPE_NAME,
59
            'type'    => $this->type->typeSerialize(),
60
            'message' => $this->message,
61
            'source'  => $this->source->typeSerialize(),
62
        ];
63
    }
64
65
    public function getType(): PassportElementType
66
    {
67
        return $this->type;
68
    }
69
70
    public function getMessage(): string
71
    {
72
        return $this->message;
73
    }
74
75
    public function getSource(): PassportElementErrorSource
76
    {
77
        return $this->source;
78
    }
79
}
80