File tree Expand file tree Collapse file tree 3 files changed +16
-8
lines changed
Expand file tree Collapse file tree 3 files changed +16
-8
lines changed Original file line number Diff line number Diff line change 88$ envConfig = PersistentState::loadEnvConfig (); // Load environment configuration (or use your own implementation)
99
1010$ server = new Server (
11+ $ envConfig ['HOST_ADDR ' ] . ': ' . $ envConfig ['HOST_PORT ' ],
12+ null ,
1113 new PersistentState (
1214 $ envConfig ['TOKEN ' ],
1315 $ envConfig ['STORAGE_TYPE ' ] ?? 'filesystem ' ,
1416 $ envConfig ['JSON_PATH ' ] ?? 'json/verify.json ' ,
15- ),
16- $ envConfig ['HOST_ADDR ' ] . ': ' . $ envConfig ['HOST_PORT ' ]
17+ )
1718);
1819
1920//$server->init(null, true); // Standalone without an event loop or ReactPHP server
Original file line number Diff line number Diff line change @@ -38,6 +38,13 @@ class Server {
3838 * */
3939 protected LoopInterface $ loop ;
4040
41+ /**
42+ * The logger.
43+ *
44+ * @var LoggerInterface Logger.
45+ */
46+ protected LoggerInterface $ logger ;
47+
4148 /**
4249 * The server instance.
4350 *
@@ -50,7 +57,7 @@ class Server {
5057 *
5158 * @var SocketServer Socket server.
5259 */
53- protected SocketServer $ socket ;
60+ protected SocketServer $ socket ;
5461
5562 /**
5663 * Whether the server has been initialized.
@@ -75,12 +82,12 @@ class Server {
7582 private array $ endpoints = [];
7683
7784 public function __construct (
78- private PersistentState $ state ,
7985 private string $ hostAddr ,
80- private ?LoggerInterface $ logger = null
86+ private ?PersistentState $ state = null
8187 ) {
82- $ this ->endpoints ['/ ' ] = new VerifiedEndpoint ($ state );
83- $ this ->endpoints ['/verified ' ] = &$ this ->endpoints ['/ ' ];
88+ if ($ state ) {
89+ $ this ->endpoints = ['/ ' => new VerifiedEndpoint ($ state ), '/verified ' => &$ this ->endpoints ['/ ' ]];
90+ }
8491 }
8592
8693 /**
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ protected function setUp(): void
2525 $ storageType = $ envConfig ['STORAGE_TYPE ' ] ?? 'filesystem ' ;
2626 $ jsonPath = $ envConfig ['JSON_PATH ' ] ?? 'json/verify.json ' ;
2727 $ state = new PersistentState ($ civToken , $ storageType , $ jsonPath );
28- $ this ->server = new Server ($ state , $ hostAddr );
28+ $ this ->server = new Server ($ hostAddr , null , $ state );
2929 }
3030
3131 /**
You can’t perform that action at this time.
0 commit comments