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 PHPTdGram\Schema;
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
    protected string $deviceToken;
22
23
    /**
24
     * True, if App Sandbox is enabled.
25
     */
26
    protected bool $isAppSandbox;
27
28
    /**
29
     * True, if push notifications should be additionally encrypted.
30
     */
31
    protected bool $encrypt;
32
33
    public function __construct(string $deviceToken, bool $isAppSandbox, bool $encrypt)
34
    {
35
        parent::__construct();
36
37
        $this->deviceToken  = $deviceToken;
38
        $this->isAppSandbox = $isAppSandbox;
39
        $this->encrypt      = $encrypt;
40
    }
41
42
    public static function fromArray(array $array): DeviceTokenApplePushVoIP
43
    {
44
        return new static(
45
            $array['device_token'],
46
            $array['is_app_sandbox'],
47
            $array['encrypt'],
48
        );
49
    }
50
51
    public function typeSerialize(): array
52
    {
53
        return [
54
            '@type'          => static::TYPE_NAME,
55
            'device_token'   => $this->deviceToken,
56
            'is_app_sandbox' => $this->isAppSandbox,
57
            'encrypt'        => $this->encrypt,
58
        ];
59
    }
60
61
    public function getDeviceToken(): string
62
    {
63
        return $this->deviceToken;
64
    }
65
66
    public function getIsAppSandbox(): bool
67
    {
68
        return $this->isAppSandbox;
69
    }
70
71
    public function getEncrypt(): bool
72
    {
73
        return $this->encrypt;
74
    }
75
}
76