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

In this article

Constructor

Parameters

$argsarray|string|nulloptional
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

Source

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

VersionDescription
1.6Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.