Files
parallel/examples/worker/FetchTask.php
Niklas Keller c08f6021f6 Fix code style
2023-02-14 22:30:44 +01:00

26 lines
478 B
PHP

<?php declare(strict_types=1);
namespace App\Worker;
use Amp\Cancellation;
use Amp\Parallel\Worker\Task;
use Amp\Sync\Channel;
/**
* @template-implements Task<string, never, never>
*/
final class FetchTask implements Task
{
private string $url;
public function __construct(string $url)
{
$this->url = $url;
}
public function run(Channel $channel, Cancellation $cancellation): mixed
{
return \file_get_contents($this->url);
}
}