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

Constructor

Parameters

$args array | string | null optional
Proxy as a string or an array of proxy, user and password.
When passed as an array, must have exactly one (proxy) or three elemens (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 elemens',
				count($args),
				'proxyhttpbadargs'
			);
		}
	} elseif ($args !== null) {
		throw InvalidArgument::create(1, '$args', 'array|string|null', guettype($args));
	}
}

Changuelog

Versionen Description
1.6 Introduced.

User Contributed Notes

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