public __construct ( array $params = [] ) | ||
$params | array | A hash of connection parameters: - host: Hostname of server (DEFAULT: localhost). Optionally prefixed with protocol scheme. - port: Port of server (DEFAULT: 4190). - user: Login username (optional). - password: Login password (optional). - authmethod: Type of login to perform (see $supportedAuthMethods) (DEFAULT: AUTH_AUTOMATIC). - euser: Effective user. If authenticating as an administrator, login as this user. - bypassauth: Skip the authentication phase. Useful if passing an already open socket. - secure: Security layer requested. One of: - true: (TLS if available/necessary) [DEFAULT] - false: (No encryption) - 'ssl': (Auto-detect SSL version) - 'sslv2': (Force SSL version 3) - 'sslv3': (Force SSL version 2) - 'tls': (TLS; started via protocol-level negotation over unencrypted channel) - 'tlsv1': (TLS version 1.x connection) - context: Additional options for stream_context_create(). - logger: A log handler, must implement debug(). |
public function __construct($params = array())
{
$this->_params = array_merge(array('authmethod' => self::AUTH_AUTOMATIC, 'bypassauth' => false, 'context' => array(), 'euser' => null, 'host' => 'localhost', 'logger' => null, 'password' => '', 'port' => 4190, 'secure' => true, 'timeout' => 5, 'user' => ''), $params);
/* Try to include the Auth_SASL package. If the package is not
* available, we disable the authentication methods that depend upon
* it. */
if (!class_exists('Auth_SASL')) {
$this->_debug('Auth_SASL not present');
$this->supportedAuthMethods = array_diff($this->supportedAuthMethods, $this->supportedSASLAuthMethods);
}
if ($this->_params['logger']) {
$this->setLogger($this->_params['logger']);
}
if (strlen($this->_params['user']) && strlen($this->_params['password'])) {
$this->_handleConnectAndLogin();
}
}