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 AurimasNiekis\TdLibSchema;
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
     * @var int
22
     */
23
    protected int $muteFor;
24
25
    /**
26
     * The name of an audio file to be used for notification sounds; only applies to iOS applications.
27
     *
28
     * @var string
29
     */
30
    protected string $sound;
31
32
    /**
33
     * True, if message content should be displayed in notifications.
34
     *
35
     * @var bool
36
     */
37
    protected bool $showPreview;
38
39
    /**
40
     * True, if notifications for incoming pinned messages will be created as for an ordinary unread message.
41
     *
42
     * @var bool
43
     */
44
    protected bool $disablePinnedMessageNotifications;
45
46
    /**
47
     * True, if notifications for messages with mentions will be created as for an ordinary unread message.
48
     *
49
     * @var bool
50
     */
51
    protected bool $disableMentionNotifications;
52
53
    public function __construct(
54
        int $muteFor,
55
        string $sound,
56
        bool $showPreview,
57
        bool $disablePinnedMessageNotifications,
58
        bool $disableMentionNotifications
59
    ) {
60
        $this->muteFor                           = $muteFor;
61
        $this->sound                             = $sound;
62
        $this->showPreview                       = $showPreview;
63
        $this->disablePinnedMessageNotifications = $disablePinnedMessageNotifications;
64
        $this->disableMentionNotifications       = $disableMentionNotifications;
65
    }
66
67
    public static function fromArray(array $array): ScopeNotificationSettings
68
    {
69
        return new static(
70
            $array['mute_for'],
71
            $array['sound'],
72
            $array['show_preview'],
73
            $array['disable_pinned_message_notifications'],
74
            $array['disable_mention_notifications'],
75
        );
76
    }
77
78
    public function typeSerialize(): array
79
    {
80
        return [
81
            '@type'                                => static::TYPE_NAME,
82
            'mute_for'                             => $this->muteFor,
83
            'sound'                                => $this->sound,
84
            'show_preview'                         => $this->showPreview,
85
            'disable_pinned_message_notifications' => $this->disablePinnedMessageNotifications,
86
            'disable_mention_notifications'        => $this->disableMentionNotifications,
87
        ];
88
    }
89
90
    public function getMuteFor(): int
91
    {
92
        return $this->muteFor;
93
    }
94
95
    public function getSound(): string
96
    {
97
        return $this->sound;
98
    }
99
100
    public function getShowPreview(): bool
101
    {
102
        return $this->showPreview;
103
    }
104
105
    public function getDisablePinnedMessageNotifications(): bool
106
    {
107
        return $this->disablePinnedMessageNotifications;
108
    }
109
110
    public function getDisableMentionNotifications(): bool
111
    {
112
        return $this->disableMentionNotifications;
113
    }
114
}
115