Completed
Push — master ( 131e54...362b30 )
by Arthur
01:56
created

ClientConfig::setContextOptions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace WSSC\Components;
4
5
6
use WSSC\Contracts\WscCommonsContract;
7
8
class ClientConfig
9
{
10
11
    private $scheme;
12
    private $host;
13
    private $user;
14
    private $password;
15
    private $port;
16
17
    private $timeout = WscCommonsContract::DEFAULT_TIMEOUT;
18
    private $headers = [];
19
    private $fragmentSize = WscCommonsContract::DEFAULT_FRAGMENT_SIZE;
20
    private $context;
21
22
    private $contextOptions = [];
23
24
    /**
25
     * @return int
26
     */
27
    public function getTimeout(): int
28
    {
29
        return $this->timeout;
30
    }
31
32
    /**
33
     * @param int $timeout
34
     */
35
    public function setTimeout(int $timeout)
36
    {
37
        $this->timeout = $timeout;
38
    }
39
40
    /**
41
     * @return array
42
     */
43
    public function getHeaders(): array
44
    {
45
        return $this->headers;
46
    }
47
48
    /**
49
     * @param array $headers
50
     */
51
    public function setHeaders(array $headers)
52
    {
53
        $this->headers = $headers;
54
    }
55
56
    /**
57
     * @return int
58
     */
59
    public function getFragmentSize(): int
60
    {
61
        return $this->fragmentSize;
62
    }
63
64
    /**
65
     * @param int $fragmentSize
66
     */
67
    public function setFragmentSize(int $fragmentSize)
68
    {
69
        $this->fragmentSize = $fragmentSize;
70
    }
71
72
    /**
73
     * @return mixed
74
     */
75
    public function getContext()
76
    {
77
        return $this->context;
78
    }
79
80
    /**
81
     * @param mixed $context
82
     */
83
    public function setContext($context)
84
    {
85
        $this->context = $context;
86
    }
87
88
    /**
89
     * @return mixed
90
     */
91
    public function getScheme(): string
92
    {
93
        return $this->scheme;
94
    }
95
96
    /**
97
     * @param void $scheme
98
     */
99
    public function setScheme($scheme): void
100
    {
101
        $this->scheme = $scheme;
102
    }
103
104
    /**
105
     * @return string
106
     */
107
    public function getHost(): string
108
    {
109
        return $this->host;
110
    }
111
112
    /**
113
     * @param void $host
114
     */
115
    public function setHost($host): void
116
    {
117
        $this->host = $host;
118
    }
119
120
    /**
121
     * @return string
122
     */
123
    public function getUser(): string
124
    {
125
        return $this->user;
126
    }
127
128
    /**
129
     * @param array $urlParts
130
     */
131
    public function setUser(array $urlParts): void
132
    {
133
        $this->user = isset($urlParts['user']) ? $urlParts['user'] : '';
134
    }
135
136
    /**
137
     * @return string
138
     */
139
    public function getPassword(): string
140
    {
141
        return $this->password;
142
    }
143
144
    /**
145
     * @param array $urlParts
146
     */
147
    public function setPassword(array $urlParts): void
148
    {
149
        $this->password = isset($urlParts['pass']) ? $urlParts['pass'] : '';
150
    }
151
152
    /**
153
     * @return string
154
     */
155
    public function getPort(): string
156
    {
157
        return $this->port;
158
    }
159
160
    /**
161
     * @param array $urlParts
162
     */
163
    public function setPort(array $urlParts): void
164
    {
165
        $this->port = isset($urlParts['port']) ? $urlParts['port'] : ($this->scheme === 'wss' ? 443 : 80);
166
    }
167
168
    /**
169
     * @return array
170
     */
171
    public function getContextOptions(): array
172
    {
173
        return $this->contextOptions;
174
    }
175
176
    /**
177
     * @param array $contextOptions
178
     */
179
    public function setContextOptions($contextOptions)
180
    {
181
        $this->contextOptions = $contextOptions;
182
    }
183
}