From c2bc7e93af40cccf11c9697813e7c6bd92e0783f Mon Sep 17 00:00:00 2001 From: divinity76 Date: Wed, 6 Nov 2024 10:54:48 +0100 Subject: [PATCH] [1.12] AbstractBinaryInput::getRawBinary() (#632) * AbstractBinaryInput::getRawBinary() simple complement to AbstractBinaryInput::getBase64() as usual, naming is hard, some possible names: getBinary getRawBinary getRawBinaryData getString getRawString ~ * StyleCI * Fixed phpdoc --------- Co-authored-by: Graham Campbell --- src/PageUtils/AbstractBinaryInput.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/PageUtils/AbstractBinaryInput.php b/src/PageUtils/AbstractBinaryInput.php index a16e4498..938ea1a5 100644 --- a/src/PageUtils/AbstractBinaryInput.php +++ b/src/PageUtils/AbstractBinaryInput.php @@ -41,9 +41,11 @@ public function getResponseReader(): ResponseReader /** * Get base64 representation of the file. * + * @param int|null $timeout + * * @return mixed */ - public function getBase64(int $timeout = null) + public function getBase64(?int $timeout = null) { $response = $this->responseReader->waitForResponse($timeout); @@ -54,10 +56,23 @@ public function getBase64(int $timeout = null) return $response->getResultData('data'); } + /** + * Get raw binary data. + * + * @param int|null $timeout + * + * @return string + */ + public function getRawBinary(int $timeout = null): string + { + return \base64_decode($this->getBase64($timeout), true); + } + /** * Save data to the given file. * * @param string $path + * @param int $timeout * * @throws FilesystemException * @throws ScreenshotFailed