EditProxy::typeSerialize()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 7
nc 1
nop 0
dl 0
loc 9
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
 * Edits an existing proxy server for network requests. Can be called before authorization.
13
 */
14
class EditProxy extends TdFunction
15
{
16
    public const TYPE_NAME = 'editProxy';
17
18
    /**
19
     * Proxy identifier.
20
     */
21
    protected int $proxyId;
22
23
    /**
24
     * Proxy server IP address.
25
     */
26
    protected string $server;
27
28
    /**
29
     * Proxy server port.
30
     */
31
    protected int $port;
32
33
    /**
34
     * True, if the proxy should be enabled.
35
     */
36
    protected bool $enable;
37
38
    /**
39
     * Proxy type.
40
     */
41
    protected ProxyType $type;
42
43
    public function __construct(int $proxyId, string $server, int $port, bool $enable, ProxyType $type)
44
    {
45
        $this->proxyId = $proxyId;
46
        $this->server  = $server;
47
        $this->port    = $port;
48
        $this->enable  = $enable;
49
        $this->type    = $type;
50
    }
51
52
    public static function fromArray(array $array): EditProxy
53
    {
54
        return new static(
55
            $array['proxy_id'],
56
            $array['server'],
57
            $array['port'],
58
            $array['enable'],
59
            TdSchemaRegistry::fromArray($array['type']),
60
        );
61
    }
62
63
    public function typeSerialize(): array
64
    {
65
        return [
66
            '@type'    => static::TYPE_NAME,
67
            'proxy_id' => $this->proxyId,
68
            'server'   => $this->server,
69
            'port'     => $this->port,
70
            'enable'   => $this->enable,
71
            'type'     => $this->type->typeSerialize(),
72
        ];
73
    }
74
75
    public function getProxyId(): int
76
    {
77
        return $this->proxyId;
78
    }
79
80
    public function getServer(): string
81
    {
82
        return $this->server;
83
    }
84
85
    public function getPort(): int
86
    {
87
        return $this->port;
88
    }
89
90
    public function getEnable(): bool
91
    {
92
        return $this->enable;
93
    }
94
95
    public function getType(): ProxyType
96
    {
97
        return $this->type;
98
    }
99
}
100