99use Http \Client \Common \Plugin \ContentLengthPlugin ;
1010use Http \Client \Common \Plugin \DecoderPlugin ;
1111use Http \Client \Common \Plugin \HeaderDefaultsPlugin ;
12+ use Http \Client \Common \PluginClient ;
1213use Http \Client \Common \PluginClientFactory ;
1314use Http \Client \Socket \Client ;
14- use Http \Discovery \UriFactoryDiscovery ;
15- use Psr \Http \Client \ClientInterface ;
15+ use Http \Discovery \Psr17FactoryDiscovery ;
1616
1717final class DockerClientFactory
1818{
19- public static function create (array $ config = [], PluginClientFactory $ pluginClientFactory = null ): ClientInterface
19+ public static function create (array $ config = [], PluginClientFactory $ pluginClientFactory = null ): PluginClient
2020 {
2121 if (!\array_key_exists ('remote_socket ' , $ config )) {
2222 $ config ['remote_socket ' ] = 'unix:///var/run/docker.sock ' ;
2323 }
2424
2525 $ socketClient = new Client ($ config );
2626
27- $ uriFactory = UriFactoryDiscovery:: find ();
28- $ host = \ preg_match ('/unix:\/\// ' , $ config ['remote_socket ' ]) ? 'http://localhost ' : $ config ['remote_socket ' ];
27+ $ uriFactory = Psr17FactoryDiscovery:: findUriFactory ();
28+ $ host = preg_match ('/unix:\/\// ' , $ config ['remote_socket ' ]) ? 'http://localhost ' : $ config ['remote_socket ' ];
2929
30- $ pluginClientFactory = $ pluginClientFactory ?? new PluginClientFactory ();
30+ $ pluginClientFactory ??= new PluginClientFactory ();
3131
3232 return $ pluginClientFactory ->createClient (
3333 $ socketClient ,
@@ -37,7 +37,7 @@ public static function create(array $config = [], PluginClientFactory $pluginCli
3737 new AddPathPlugin ($ uriFactory ->createUri ('/v1.41 ' )),
3838 new AddHostPlugin ($ uriFactory ->createUri ($ host )),
3939 new HeaderDefaultsPlugin ([
40- 'host ' => \ parse_url ($ host , \PHP_URL_HOST ),
40+ 'host ' => parse_url ($ host , \PHP_URL_HOST ),
4141 ]),
4242 ],
4343 [
@@ -46,29 +46,29 @@ public static function create(array $config = [], PluginClientFactory $pluginCli
4646 );
4747 }
4848
49- public static function createFromEnv (PluginClientFactory $ pluginClientFactory = null ): ClientInterface
49+ public static function createFromEnv (PluginClientFactory $ pluginClientFactory = null ): PluginClient
5050 {
5151 $ options = [
52- 'remote_socket ' => \ getenv ('DOCKER_HOST ' ) ? \ getenv ('DOCKER_HOST ' ) : 'unix:///var/run/docker.sock ' ,
52+ 'remote_socket ' => getenv ('DOCKER_HOST ' ) ? getenv ('DOCKER_HOST ' ) : 'unix:///var/run/docker.sock ' ,
5353 ];
5454
55- if (\ getenv ('DOCKER_TLS_VERIFY ' ) && '1 ' === \ getenv ('DOCKER_TLS_VERIFY ' )) {
56- if (!\ getenv ('DOCKER_CERT_PATH ' )) {
55+ if (getenv ('DOCKER_TLS_VERIFY ' ) && '1 ' === getenv ('DOCKER_TLS_VERIFY ' )) {
56+ if (!getenv ('DOCKER_CERT_PATH ' )) {
5757 throw new \RuntimeException ('Connection to docker has been set to use TLS, but no PATH is defined for certificate in DOCKER_CERT_PATH docker environment variable ' );
5858 }
5959
60- $ cafile = \ getenv ('DOCKER_CERT_PATH ' ).\DIRECTORY_SEPARATOR .'ca.pem ' ;
61- $ certfile = \ getenv ('DOCKER_CERT_PATH ' ).\DIRECTORY_SEPARATOR .'cert.pem ' ;
62- $ keyfile = \ getenv ('DOCKER_CERT_PATH ' ).\DIRECTORY_SEPARATOR .'key.pem ' ;
60+ $ cafile = getenv ('DOCKER_CERT_PATH ' ).\DIRECTORY_SEPARATOR .'ca.pem ' ;
61+ $ certfile = getenv ('DOCKER_CERT_PATH ' ).\DIRECTORY_SEPARATOR .'cert.pem ' ;
62+ $ keyfile = getenv ('DOCKER_CERT_PATH ' ).\DIRECTORY_SEPARATOR .'key.pem ' ;
6363
6464 $ stream_context = [
6565 'cafile ' => $ cafile ,
6666 'local_cert ' => $ certfile ,
6767 'local_pk ' => $ keyfile ,
6868 ];
6969
70- if (\ getenv ('DOCKER_PEER_NAME ' )) {
71- $ stream_context ['peer_name ' ] = \ getenv ('DOCKER_PEER_NAME ' );
70+ if (getenv ('DOCKER_PEER_NAME ' )) {
71+ $ stream_context ['peer_name ' ] = getenv ('DOCKER_PEER_NAME ' );
7272 }
7373
7474 $ options ['ssl ' ] = true ;
0 commit comments