@@ -111,17 +111,15 @@ class Client
111
111
public function __construct (Builder $ httpClientBuilder = null , $ apiVersion = null , $ enterpriseUrl = null )
112
112
{
113
113
$ this ->responseHistory = new History ();
114
- $ this ->httpClientBuilder = $ httpClientBuilder ?: new Builder ();
115
- $ this ->getHttpClientBuilder ()->addDefaultHeaders ([
116
- 'Accept ' => sprintf ('application/vnd.github.%s+json ' , $ this ->getApiVersion ()),
117
- ]);
114
+ $ this ->httpClientBuilder = $ builder = $ httpClientBuilder ?: new Builder ();
118
115
119
- $ this -> getHttpClientBuilder () ->addPlugin (new GithubExceptionThrower ());
120
- $ this -> getHttpClientBuilder () ->addPlugin (new Plugin \HistoryPlugin ($ this ->responseHistory ));
121
- $ this -> getHttpClientBuilder () ->addPlugin (new Plugin \RedirectPlugin ());
122
- $ this -> getHttpClientBuilder () ->addPlugin (new Plugin \AddHostPlugin (UriFactoryDiscovery::find ()->createUri ('https://api.github.com ' )));
123
- $ this -> getHttpClientBuilder () ->addPlugin (new Plugin \HeaderDefaultsPlugin (array (
116
+ $ builder ->addPlugin (new GithubExceptionThrower ());
117
+ $ builder ->addPlugin (new Plugin \HistoryPlugin ($ this ->responseHistory ));
118
+ $ builder ->addPlugin (new Plugin \RedirectPlugin ());
119
+ $ builder ->addPlugin (new Plugin \AddHostPlugin (UriFactoryDiscovery::find ()->createUri ('https://api.github.com ' )));
120
+ $ builder ->addPlugin (new Plugin \HeaderDefaultsPlugin (array (
124
121
'User-Agent ' => 'php-github-api (http://github.com/KnpLabs/php-github-api) ' ,
122
+ 'Accept ' => sprintf ('application/vnd.github.%s+json ' , $ this ->getApiVersion ()),
125
123
)));
126
124
127
125
$ this ->apiVersion = $ apiVersion ?: 'v3 ' ;
@@ -290,11 +288,12 @@ public function authenticate($tokenOrLogin, $password = null, $authMethod = null
290
288
*/
291
289
private function setEnterpriseUrl ($ enterpriseUrl )
292
290
{
293
- $ this ->getHttpClientBuilder ()->removePlugin (Plugin \AddHostPlugin::class);
294
- $ this ->getHttpClientBuilder ()->removePlugin (PathPrepend::class);
291
+ $ builder = $ this ->getHttpClientBuilder ();
292
+ $ builder ->removePlugin (Plugin \AddHostPlugin::class);
293
+ $ builder ->removePlugin (PathPrepend::class);
295
294
296
- $ this -> getHttpClientBuilder () ->addPlugin (new Plugin \AddHostPlugin (UriFactoryDiscovery::find ()->createUri ($ enterpriseUrl )));
297
- $ this -> getHttpClientBuilder () ->addPlugin (new PathPrepend (sprintf ('/api/%s/ ' , $ this ->getApiVersion ())));
295
+ $ builder ->addPlugin (new Plugin \AddHostPlugin (UriFactoryDiscovery::find ()->createUri ($ enterpriseUrl )));
296
+ $ builder ->addPlugin (new PathPrepend (sprintf ('/api/%s/ ' , $ this ->getApiVersion ())));
298
297
}
299
298
300
299
/**
0 commit comments