File tree Expand file tree Collapse file tree 2 files changed +25
-8
lines changed Expand file tree Collapse file tree 2 files changed +25
-8
lines changed Original file line number Diff line number Diff line change @@ -444,24 +444,25 @@ class Client
444
444
*/
445
445
private $ _readWriteTimeout = 5000 ;
446
446
447
+ /**
448
+ * Data transport instance
449
+ * @var Transport
450
+ */
447
451
private Transport $ transport ;
448
452
449
453
/**
450
454
* Constructor
451
455
*
452
456
* @param string $host Host of the FastCGI application
453
457
* @param int $port Port of the FastCGI application
454
- * @param string $transport Transport
458
+ * @param Transport $transport Transport
455
459
*/
456
- public function __construct ($ host , $ port , string $ transport = ' stream ' )
460
+ public function __construct ($ host , $ port , Transport $ transport )
457
461
{
458
462
$ this ->_host = $ host ;
459
463
$ this ->_port = $ port ;
460
464
461
- $ this ->transport = match ($ transport ) {
462
- 'stream ' => new StreamTransport (),
463
- 'socket ' => new SocketTransport (),
464
- };
465
+ $ this ->transport = $ transport ;
465
466
}
466
467
467
468
/**
Original file line number Diff line number Diff line change 3
3
namespace FPM ;
4
4
5
5
use FPM \FastCGI \Client ;
6
+ use FPM \FastCGI \SocketTransport ;
7
+ use FPM \FastCGI \StreamTransport ;
8
+ use FPM \FastCGI \Transport ;
6
9
7
10
require_once 'fcgi.inc ' ;
8
11
require_once 'logreader.inc ' ;
@@ -386,6 +389,19 @@ class Tester
386
389
$ this ->clientTransport = $ clientTransport ;
387
390
}
388
391
392
+ /**
393
+ * Creates new client transport.
394
+ *
395
+ * @return Transport
396
+ */
397
+ private function createTransport ()
398
+ {
399
+ return match ($ this ->clientTransport ) {
400
+ 'stream ' => new StreamTransport (),
401
+ 'socket ' => new SocketTransport (),
402
+ };
403
+ }
404
+
389
405
/**
390
406
* @param string $ini
391
407
*/
@@ -936,11 +952,11 @@ class Tester
936
952
}
937
953
938
954
if ( ! $ keepAlive ) {
939
- return new Client ($ host , $ port , $ this ->clientTransport );
955
+ return new Client ($ host , $ port , $ this ->createTransport () );
940
956
}
941
957
942
958
if ( ! isset ($ this ->clients [$ host ][$ port ])) {
943
- $ client = new Client ($ host , $ port , $ this ->clientTransport );
959
+ $ client = new Client ($ host , $ port , $ this ->createTransport () );
944
960
$ client ->setKeepAlive (true );
945
961
$ this ->clients [$ host ][$ port ] = $ client ;
946
962
}
You can’t perform that action at this time.
0 commit comments