protected static function _getClient() { if (static::$_client === null) { static::$_client = new HttpSocket(); } static::$_client->reset(true); static::$_client->request['header'] = []; return static::$_client; }
public static function setUpBeforeClass() { $login = getenv('REMOTE_LOGIN'); $password = getenv('REMOTE_PASSWORD'); $host = getenv('REMOTE_HOST'); $port = 8443; $scheme = 'https'; if ($url = getenv('REMOTE_URL')) { $parsedUrl = parse_url($url); list($host, $port, $scheme) = [$parsedUrl['host'], $parsedUrl['port'], $parsedUrl['scheme']]; } static::$_client = new PleskX\Api\Client($host, $port, $scheme); static::$_client->setCredentials($login, $password); }
/** * Returns the client instance to the backgrond jobs server * If first param is an instance of GearmanClient it will configure the queue to use it * IF first param is false it will unset configured client to defaults * * @param GearmanClient|boolean $client null to return current instance, GearmanClient instance to configure it * to passed value, false to reset to defaults * @return GearmanClient **/ public static function client($client = null) { if ($client instanceof GearmanClient) { static::$_client = $client; static::_setServers(static::$_servers); } if ($client === false) { return static::$_client = null; } if (empty(static::$_client)) { static::$_client = new GearmanClient(); static::_setServers(static::$_servers); } return static::$_client; }