| 1: | <?php |
| 2: | namespace Worldline\Connect\Sdk; |
| 3: | |
| 4: | /** |
| 5: | * Class ProxyConfiguration |
| 6: | * |
| 7: | * @package Worldline\Connect\Sdk |
| 8: | */ |
| 9: | class ProxyConfiguration |
| 10: | { |
| 11: | /** |
| 12: | * @var string|null |
| 13: | */ |
| 14: | private ?string $host = null; |
| 15: | |
| 16: | /** |
| 17: | * @var string|int|null |
| 18: | */ |
| 19: | private $port = null; |
| 20: | |
| 21: | /** |
| 22: | * @var string|null |
| 23: | */ |
| 24: | private ?string $username = null; |
| 25: | |
| 26: | /** |
| 27: | * @var string|null |
| 28: | */ |
| 29: | private ?string $password = null; |
| 30: | |
| 31: | /** |
| 32: | * @param string $host |
| 33: | * @param string|int|null $port |
| 34: | * @param string|null $username |
| 35: | * @param string|null $password |
| 36: | */ |
| 37: | public function __construct(string $host, $port = null, ?string $username = null, ?string $password = null) |
| 38: | { |
| 39: | if ($host) { |
| 40: | $this->host = $host; |
| 41: | $this->port = $port; |
| 42: | $this->username = $username; |
| 43: | $this->password = $password; |
| 44: | } |
| 45: | } |
| 46: | |
| 47: | /** |
| 48: | * @return string |
| 49: | */ |
| 50: | public function getCurlProxy(): string |
| 51: | { |
| 52: | if (!is_null($this->host)) { |
| 53: | return $this->host . (is_null($this->port) ? '' : ':'. $this->port); |
| 54: | } |
| 55: | return ''; |
| 56: | } |
| 57: | |
| 58: | /** |
| 59: | * @return string |
| 60: | */ |
| 61: | public function getCurlProxyUserPwd(): string |
| 62: | { |
| 63: | if (!is_null($this->username)) { |
| 64: | return $this->username . (is_null($this->password) ? '' : ':'. $this->password); |
| 65: | } |
| 66: | return ''; |
| 67: | } |
| 68: | } |
| 69: |