Http::__construct( array|string|null $args = null )

Constructor


Parameters

$args

(Optional) Proxy as a string or an array of proxy, user and password.<br> When passed as an array, must have exactly one (proxy) or three elements (proxy, user, password).

Default value: null


Source

File: wp-includes/Requests/src/Proxy/Http.php

	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));
		}
	}

Changelog

Changelog
Version Description
1.6 Introduced.