diff --git a/src/Utils/Downloader/DownloaderDirect.php b/src/Utils/Downloader/DownloaderDirect.php index 119dbe8..e6974bf 100644 --- a/src/Utils/Downloader/DownloaderDirect.php +++ b/src/Utils/Downloader/DownloaderDirect.php @@ -9,6 +9,7 @@ class DownloaderDirect extends Downloader { protected function __construct( protected string $path, + protected ?int $speed = null, ) { parent::__construct(basename($path)); } @@ -35,6 +36,16 @@ public function autoMimeType(): self return $this; } + /** + * Change the speed of the download, lower is faster. + */ + public function speed(int $speed): self + { + $this->speed = $speed; + + return $this; + } + /** * Trigger the download. */ @@ -50,6 +61,9 @@ public function get(): void echo fread($file, 1024 * 8); ob_flush(); flush(); + if ($this->speed) { + usleep($this->speed); + } } fclose($file);