@@ -111,17 +111,15 @@ class Client
111111 public function __construct (Builder $ httpClientBuilder = null , $ apiVersion = null , $ enterpriseUrl = null )
112112 {
113113 $ 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 ();
118115
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 (
124121 'User-Agent ' => 'php-github-api (http://github.com/KnpLabs/php-github-api) ' ,
122+ 'Accept ' => sprintf ('application/vnd.github.%s+json ' , $ this ->getApiVersion ()),
125123 )));
126124
127125 $ this ->apiVersion = $ apiVersion ?: 'v3 ' ;
@@ -290,11 +288,12 @@ public function authenticate($tokenOrLogin, $password = null, $authMethod = null
290288 */
291289 private function setEnterpriseUrl ($ enterpriseUrl )
292290 {
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);
295294
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 ())));
298297 }
299298
300299 /**
0 commit comments