Skip to content

Commit

Permalink
[1.12] AbstractBinaryInput::getRawBinary() (#632)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
divinity76 and GrahamCampbell authored Nov 6, 2024
1 parent e30b0bd commit c2bc7e9
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/PageUtils/AbstractBinaryInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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
Expand Down

0 comments on commit c2bc7e9

Please sign in to comment.