ScopeNotificationSettings::fromArray()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 1
dl 0
loc 8
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
 * Contains information about notification settings for several chats.
13
 */
14
class ScopeNotificationSettings extends TdObject
15
{
16
    public const TYPE_NAME = 'scopeNotificationSettings';
17
18
    /**
19
     * Time left before notifications will be unmuted, in seconds.
20
     */
21
    protected int $muteFor;
22
23
    /**
24
     * The name of an audio file to be used for notification sounds; only applies to iOS applications.
25
     */
26
    protected string $sound;
27
28
    /**
29
     * True, if message content should be displayed in notifications.
30
     */
31
    protected bool $showPreview;
32
33
    /**
34
     * True, if notifications for incoming pinned messages will be created as for an ordinary unread message.
35
     */
36
    protected bool $disablePinnedMessageNotifications;
37
38
    /**
39
     * True, if notifications for messages with mentions will be created as for an ordinary unread message.
40
     */
41
    protected bool $disableMentionNotifications;
42
43
    public function __construct(
44
        int $muteFor,
45
        string $sound,
46
        bool $showPreview,
47
        bool $disablePinnedMessageNotifications,
48
        bool $disableMentionNotifications
49
    ) {
50
        $this->muteFor                           = $muteFor;
51
        $this->sound                             = $sound;
52
        $this->showPreview                       = $showPreview;
53
        $this->disablePinnedMessageNotifications = $disablePinnedMessageNotifications;
54
        $this->disableMentionNotifications       = $disableMentionNotifications;
55
    }
56
57
    public static function fromArray(array $array): ScopeNotificationSettings
58
    {
59
        return new static(
60
            $array['mute_for'],
61
            $array['sound'],
62
            $array['show_preview'],
63
            $array['disable_pinned_message_notifications'],
64
            $array['disable_mention_notifications'],
65
        );
66
    }
67
68
    public function typeSerialize(): array
69
    {
70
        return [
71
            '@type'                                => static::TYPE_NAME,
72
            'mute_for'                             => $this->muteFor,
73
            'sound'                                => $this->sound,
74
            'show_preview'                         => $this->showPreview,
75
            'disable_pinned_message_notifications' => $this->disablePinnedMessageNotifications,
76
            'disable_mention_notifications'        => $this->disableMentionNotifications,
77
        ];
78
    }
79
80
    public function getMuteFor(): int
81
    {
82
        return $this->muteFor;
83
    }
84
85
    public function getSound(): string
86
    {
87
        return $this->sound;
88
    }
89
90
    public function getShowPreview(): bool
91
    {
92
        return $this->showPreview;
93
    }
94
95
    public function getDisablePinnedMessageNotifications(): bool
96
    {
97
        return $this->disablePinnedMessageNotifications;
98
    }
99
100
    public function getDisableMentionNotifications(): bool
101
    {
102
        return $this->disableMentionNotifications;
103
    }
104
}
105