AddProxy::typeSerialize()   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 0
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
 * Adds a proxy server for network requests. Can be called before authorization.
13
 */
14
class AddProxy extends TdFunction
15
{
16
    public const TYPE_NAME = 'addProxy';
17
18
    /**
19
     * Proxy server IP address.
20
     */
21
    protected string $server;
22
23
    /**
24
     * Proxy server port.
25
     */
26
    protected int $port;
27
28
    /**
29
     * True, if the proxy should be enabled.
30
     */
31
    protected bool $enable;
32
33
    /**
34
     * Proxy type.
35
     */
36
    protected ProxyType $type;
37
38
    public function __construct(string $server, int $port, bool $enable, ProxyType $type)
39
    {
40
        $this->server = $server;
41
        $this->port   = $port;
42
        $this->enable = $enable;
43
        $this->type   = $type;
44
    }
45
46
    public static function fromArray(array $array): AddProxy
47
    {
48
        return new static(
49
            $array['server'],
50
            $array['port'],
51
            $array['enable'],
52
            TdSchemaRegistry::fromArray($array['type']),
53
        );
54
    }
55
56
    public function typeSerialize(): array
57
    {
58
        return [
59
            '@type'  => static::TYPE_NAME,
60
            'server' => $this->server,
61
            'port'   => $this->port,
62
            'enable' => $this->enable,
63
            'type'   => $this->type->typeSerialize(),
64
        ];
65
    }
66
67
    public function getServer(): string
68
    {
69
        return $this->server;
70
    }
71
72
    public function getPort(): int
73
    {
74
        return $this->port;
75
    }
76
77
    public function getEnable(): bool
78
    {
79
        return $this->enable;
80
    }
81
82
    public function getType(): ProxyType
83
    {
84
        return $this->type;
85
    }
86
}
87