*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @return void
*/
- protected function __construct () {
+ private function __construct () {
// Call parent constructor!
parent::__construct(__CLASS__);
}
$compressorInstance = NULL;
// Get new instance
- if ((function_exists('bzcompress')) && (function_exists('bzdecompress'))) {
+ if (extension_loaded('bzip2')) {
// Compressor can maybe be used
$compressorInstance = new Bzip2Compressor();
- } // END - if
+ }
// Return the compressor instance
return $compressorInstance;
*
* @param $streamData Mixed non-object stream data
* @return $streamData The compressed stream data
- * @throws InvalidObjectException If the stream is an object
*/
- public function compressStream ($streamData) {
- if (is_object($streamData)) {
- // Throw an exception
- throw new InvalidObjectException($streamData, self::EXCEPTION_UNEXPECTED_OBJECT);
- } // END - if
+ public function compressStream (string $streamData) {
+ // Compress it
+ $streamData = bzcompress($streamData, 1);
// Return the compressed stream
- return bzcompress($streamData, 1);
+ return $streamData;
}
/**
*
* @param $streamData Mixed non-object stream data
* @return $streamData The decompressed stream data
- * @throws InvalidObjectException If the stream is an object
*/
- public function decompressStream ($streamData) {
- if (is_object($streamData)) {
- // Throw an exception
- throw new InvalidObjectException($streamData, self::EXCEPTION_UNEXPECTED_OBJECT);
- } // END - if
-
+ public function decompressStream (string $streamData) {
// Decompress it
$streamData = bzdecompress($streamData, true);