WpOrg\Requests\Proxy

Http::__constructpublicWP 1.6

Constructor

Method of the class: Http{}

No Hooks.

Returns

null. Nothing (null).

Usage

$Http = new Http();
$Http->__construct( $args );
$args(array|string|null)
Proxy as a string or an array of proxy, user and password. When passed as an array, must have exactly one (proxy) or three elements (proxy, user, password).
Default: null

Changelog

Since 1.6 Introduced.

Http::__construct() code WP 6.8.1

public function __construct($args = null) {
	if (is_string($args)) {
		$this->proxy = $args;
	} elseif (is_array($args)) {
		if (count($args) === 1) {
			list($this->proxy) = $args;
		} elseif (count($args) === 3) {
			list($this->proxy, $this->user, $this->pass) = $args;
			$this->use_authentication                    = true;
		} else {
			throw ArgumentCount::create(
				'an array with exactly one element or exactly three elements',
				count($args),
				'proxyhttpbadargs'
			);
		}
	} elseif ($args !== null) {
		throw InvalidArgument::create(1, '$args', 'array|string|null', gettype($args));
	}
}