Skip to content

Commit

Permalink
AbstractBinaryInput::getRawBinary()
Browse files Browse the repository at this point in the history
simple complement to AbstractBinaryInput::getBase64()

as usual, naming is hard, some possible names:
getBinary
getRawBinary
getRawBinaryData
getString
getRawString
~
  • Loading branch information
divinity76 authored Jun 19, 2024
1 parent dc463f0 commit ecf8bd1
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/PageUtils/AbstractBinaryInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ 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.
*
Expand Down Expand Up @@ -89,7 +100,7 @@ public function saveToFile(string $path, int $timeout = 5000): void
}
}

$file = \fopen($path, 'w');
$file = \fopen($path, 'wb');
\stream_filter_append($file, 'convert.base64-decode');
\fwrite($file, $response->getResultData('data'));
\fclose($file);
Expand Down

0 comments on commit ecf8bd1

Please sign in to comment.