Total Complexity | 7 |
Total Lines | 51 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
14 | class PushMessageContentVoiceNote extends PushMessageContent |
||
15 | { |
||
16 | public const TYPE_NAME = 'pushMessageContentVoiceNote'; |
||
17 | |||
18 | /** |
||
19 | * Message content; may be null. |
||
20 | * |
||
21 | * @var VoiceNote|null |
||
22 | */ |
||
23 | protected ?VoiceNote $voiceNote; |
||
24 | |||
25 | /** |
||
26 | * True, if the message is a pinned message with the specified content. |
||
27 | * |
||
28 | * @var bool |
||
29 | */ |
||
30 | protected bool $isPinned; |
||
31 | |||
32 | public function __construct(?VoiceNote $voiceNote, bool $isPinned) |
||
33 | { |
||
34 | parent::__construct(); |
||
35 | |||
36 | $this->voiceNote = $voiceNote; |
||
37 | $this->isPinned = $isPinned; |
||
38 | } |
||
39 | |||
40 | public static function fromArray(array $array): PushMessageContentVoiceNote |
||
41 | { |
||
42 | return new static( |
||
43 | (isset($array['voice_note']) ? TdSchemaRegistry::fromArray($array['voice_note']) : null), |
||
44 | $array['is_pinned'], |
||
45 | ); |
||
46 | } |
||
47 | |||
48 | public function typeSerialize(): array |
||
49 | { |
||
50 | return [ |
||
51 | '@type' => static::TYPE_NAME, |
||
52 | 'voice_note' => (isset($this->voiceNote) ? $this->voiceNote : null), |
||
53 | 'is_pinned' => $this->isPinned, |
||
54 | ]; |
||
55 | } |
||
56 | |||
57 | public function getVoiceNote(): ?VoiceNote |
||
60 | } |
||
61 | |||
62 | public function getIsPinned(): bool |
||
65 | } |
||
66 | } |
||
67 |