maxLength = $maxLength; $this->stream = new PumpStream(function ($length) use (&$maxLength) { $length = min($length, $maxLength); $maxLength -= $length; if ($length > 0) { return openssl_random_pseudo_bytes($length); } }); } /** * @return int|null */ public function getSize() { return $this->maxLength; } }