-
-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathProxy.php
More file actions
99 lines (77 loc) · 1.9 KB
/
Proxy.php
File metadata and controls
99 lines (77 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
declare(strict_types=1);
namespace Shapecode\FUT\Client\Model;
class Proxy implements ProxyInterface
{
/** @var string */
protected $protocol;
/** @var string */
protected $ip;
/** @var string */
protected $port;
/** @var string|null */
protected $username;
/** @var string|null */
protected $password;
public function __construct(
string $protocol,
string $ip,
string $port,
?string $username = null,
?string $password = null
) {
$this->protocol = $protocol;
$this->ip = $ip;
$this->port = $port;
$this->username = $username;
$this->password = $password;
}
public function getProtocol() : string
{
return $this->protocol;
}
public function getIp() : string
{
return $this->ip;
}
public function setIp(string $ip) : void
{
$this->ip = $ip;
}
public function getPort() : string
{
return $this->port;
}
public function setPort(string $port) : void
{
$this->port = $port;
}
public function getUsername() : ?string
{
return $this->username;
}
public function setUsername(?string $username) : void
{
$this->username = $username;
}
public function getPassword() : ?string
{
return $this->password;
}
public function setPassword(?string $password) : void
{
$this->password = $password;
}
public function getProxyProtocol() : string
{
$auth = '';
if ($this->getUsername() !== null) {
$auth = $this->getUsername();
if ($this->getPassword() !== null) {
$auth .= ':' . $this->getPassword();
}
$auth .= '@';
}
return $this->getProtocol() . '://' . $auth . $this->getIp() . ':' . $this->getPort();
}
}