DeviceTokenApplePushVoIP::fromArray()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
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
 * A token for Apple Push Notification service VoIP notifications.
13
 */
14
class DeviceTokenApplePushVoIP extends DeviceToken
15
{
16
    public const TYPE_NAME = 'deviceTokenApplePushVoIP';
17
18
    /**
19
     * Device token; may be empty to de-register a device.
20
     *
21
     * @var string
22
     */
23
    protected string $deviceToken;
24
25
    /**
26
     * True, if App Sandbox is enabled.
27
     *
28
     * @var bool
29
     */
30
    protected bool $isAppSandbox;
31
32
    /**
33
     * True, if push notifications should be additionally encrypted.
34
     *
35
     * @var bool
36
     */
37
    protected bool $encrypt;
38
39
    public function __construct(string $deviceToken, bool $isAppSandbox, bool $encrypt)
40
    {
41
        parent::__construct();
42
43
        $this->deviceToken  = $deviceToken;
44
        $this->isAppSandbox = $isAppSandbox;
45
        $this->encrypt      = $encrypt;
46
    }
47
48
    public static function fromArray(array $array): DeviceTokenApplePushVoIP
49
    {
50
        return new static(
51
            $array['device_token'],
52
            $array['is_app_sandbox'],
53
            $array['encrypt'],
54
        );
55
    }
56
57
    public function typeSerialize(): array
58
    {
59
        return [
60
            '@type'          => static::TYPE_NAME,
61
            'device_token'   => $this->deviceToken,
62
            'is_app_sandbox' => $this->isAppSandbox,
63
            'encrypt'        => $this->encrypt,
64
        ];
65
    }
66
67
    public function getDeviceToken(): string
68
    {
69
        return $this->deviceToken;
70
    }
71
72
    public function getIsAppSandbox(): bool
73
    {
74
        return $this->isAppSandbox;
75
    }
76
77
    public function getEncrypt(): bool
78
    {
79
        return $this->encrypt;
80
    }
81
}
82