8
8
use Rcalicdan \FiberAsync \Handlers \AsyncOperations \AwaitHandler ;
9
9
use Rcalicdan \FiberAsync \Handlers \AsyncOperations \ConcurrencyHandler ;
10
10
use Rcalicdan \FiberAsync \Handlers \AsyncOperations \FiberContextHandler ;
11
- use Rcalicdan \FiberAsync \Handlers \AsyncOperations \FileHandler ;
12
- use Rcalicdan \FiberAsync \Handlers \AsyncOperations \HttpHandler ;
13
11
use Rcalicdan \FiberAsync \Handlers \AsyncOperations \PromiseCollectionHandler ;
14
12
use Rcalicdan \FiberAsync \Handlers \AsyncOperations \PromiseHandler ;
15
13
use Rcalicdan \FiberAsync \Handlers \AsyncOperations \TimerHandler ;
@@ -51,11 +49,6 @@ class AsyncOperations implements AsyncOperationsInterface
51
49
*/
52
50
private TimerHandler $ timerHandler ;
53
51
54
- /**
55
- * @var HttpHandler Handles HTTP request operations
56
- */
57
- private HttpHandler $ httpHandler ;
58
-
59
52
/**
60
53
* @var PromiseCollectionHandler Manages collections of promises (all, race)
61
54
*/
@@ -66,11 +59,6 @@ class AsyncOperations implements AsyncOperationsInterface
66
59
*/
67
60
private ConcurrencyHandler $ concurrencyHandler ;
68
61
69
- /**
70
- * @var FileHandler Handles asynchronous file operations
71
- */
72
- private FileHandler $ fileHandler ;
73
-
74
62
/**
75
63
* Initialize the async operations system with all required handlers.
76
64
*
@@ -84,10 +72,8 @@ public function __construct()
84
72
$ this ->executionHandler = new AsyncExecutionHandler ;
85
73
$ this ->awaitHandler = new AwaitHandler ($ this ->contextHandler );
86
74
$ this ->timerHandler = new TimerHandler ;
87
- $ this ->httpHandler = new HttpHandler ;
88
75
$ this ->collectionHandler = new PromiseCollectionHandler ;
89
76
$ this ->concurrencyHandler = new ConcurrencyHandler ($ this ->executionHandler );
90
- $ this ->fileHandler = new FileHandler ();
91
77
}
92
78
93
79
/**
@@ -194,55 +180,6 @@ public function delay(float $seconds): PromiseInterface
194
180
return $ this ->timerHandler ->delay ($ seconds );
195
181
}
196
182
197
- /**
198
- * Perform an HTTP request and return a promise.
199
- *
200
- * @param string $url The URL to request
201
- * @param array $options Request options (method, headers, body, etc.)
202
- * @return PromiseInterface A promise that resolves with the response
203
- */
204
- public function fetch (string $ url , array $ options = []): PromiseInterface
205
- {
206
- return $ this ->httpHandler ->fetch ($ url , $ options );
207
- }
208
-
209
- /**
210
- * Perform an HTTP request using Guzzle HTTP client.
211
- *
212
- * @param string $method HTTP method (GET, POST, etc.)
213
- * @param string $url The URL to request
214
- * @param array $options Guzzle-specific request options
215
- * @return PromiseInterface A promise that resolves with the response
216
- */
217
- public function guzzle (string $ method , string $ url , array $ options = []): PromiseInterface
218
- {
219
- return $ this ->httpHandler ->guzzle ($ method , $ url , $ options );
220
- }
221
-
222
- /**
223
- * Get the HTTP handler for advanced HTTP operations.
224
- *
225
- * @return mixed The HTTP handler instance for direct access
226
- */
227
- public function http ()
228
- {
229
- return $ this ->httpHandler ->http ();
230
- }
231
-
232
- /**
233
- * Wrap a synchronous operation in a promise.
234
- *
235
- * This is useful for integrating blocking operations into
236
- * async workflows without blocking the event loop.
237
- *
238
- * @param callable $syncCall The synchronous operation to wrap
239
- * @return PromiseInterface A promise that resolves with the operation result
240
- */
241
- public function wrapSync (callable $ syncCall ): PromiseInterface
242
- {
243
- return $ this ->httpHandler ->wrapSync ($ syncCall );
244
- }
245
-
246
183
/**
247
184
* Wait for all promises to resolve and return their results.
248
185
*
@@ -285,113 +222,4 @@ public function concurrent(array $tasks, int $concurrency = 10): PromiseInterfac
285
222
{
286
223
return $ this ->concurrencyHandler ->concurrent ($ tasks , $ concurrency );
287
224
}
288
-
289
- /**
290
- * Read a file asynchronously.
291
- *
292
- * @param string $path The file path to read
293
- * @param array $options
294
- * @return PromiseInterface Promise that resolves with file contents
295
- */
296
- public function readFile (string $ path , array $ options = []): PromiseInterface
297
- {
298
- return $ this ->fileHandler ->readFile ($ path , $ options );
299
- }
300
-
301
- /**
302
- * Write to a file asynchronously.
303
- *
304
- * @param string $path The file path to write to
305
- * @param string $data The data to write
306
- * @param bool $append Whether to append or overwrite
307
- * @return PromiseInterface Promise that resolves with bytes written
308
- */
309
- public function writeFile (string $ path , string $ data , array $ options = []): PromiseInterface
310
- {
311
- return $ this ->fileHandler ->writeFile ($ path , $ data , $ options );
312
- }
313
-
314
- /**
315
- * Append to a file asynchronously.
316
- *
317
- * @param string $path The file path to append to
318
- * @param string $data The data to append
319
- * @return PromiseInterface Promise that resolves with bytes written
320
- */
321
- public function appendFile (string $ path , string $ data ): PromiseInterface
322
- {
323
- return $ this ->fileHandler ->appendFile ($ path , $ data );
324
- }
325
-
326
- /**
327
- * Check if file exists asynchronously.
328
- */
329
- public function fileExists (string $ path ): PromiseInterface
330
- {
331
- return $ this ->fileHandler ->fileExists ($ path );
332
- }
333
-
334
- /**
335
- * Get file information asynchronously.
336
- */
337
- public function getFileStats (string $ path ): PromiseInterface
338
- {
339
- return $ this ->fileHandler ->getFileStats ($ path );
340
- }
341
-
342
- /**
343
- * Delete a file asynchronously.
344
- */
345
- public function deleteFile (string $ path ): PromiseInterface
346
- {
347
- return $ this ->fileHandler ->deleteFile ($ path );
348
- }
349
-
350
- /**
351
- * Create a directory asynchronously.
352
- */
353
- public function createDirectory (string $ path , array $ options = []): PromiseInterface
354
- {
355
- return $ this ->fileHandler ->createDirectory ($ path , $ options );
356
- }
357
-
358
- /**
359
- * Remove a directory asynchronously.
360
- */
361
- public function removeDirectory (string $ path ): PromiseInterface
362
- {
363
- return $ this ->fileHandler ->removeDirectory ($ path );
364
- }
365
-
366
- /**
367
- * Copy a file asynchronously.
368
- */
369
- public function copyFile (string $ source , string $ destination ): PromiseInterface
370
- {
371
- return $ this ->fileHandler ->copyFile ($ source , $ destination );
372
- }
373
-
374
- /**
375
- * Rename a file asynchronously.
376
- */
377
- public function renameFile (string $ oldPath , string $ newPath ): PromiseInterface
378
- {
379
- return $ this ->fileHandler ->renameFile ($ oldPath , $ newPath );
380
- }
381
-
382
- /**
383
- * Watch a file for changes asynchronously.
384
- */
385
- public function watchFile (string $ path , callable $ callback , array $ options = []): string
386
- {
387
- return $ this ->fileHandler ->watchFile ($ path , $ callback , $ options );
388
- }
389
-
390
- /**
391
- * Unwatch a file for changes asynchronously.
392
- */
393
- public function unwatchFile (string $ watcherId ): bool
394
- {
395
- return $ this ->fileHandler ->unwatchFile ($ watcherId );
396
- }
397
225
}
0 commit comments