Continued:
[core.git] / framework / main / classes / compressor / class_Bzip2Compressor.php
index bf19554a77b538e390e3d1df3274ee7043a9c772..66c5ab0211a42616b393d373eabc3862de1521ce 100644 (file)
@@ -11,7 +11,7 @@ use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
  *
  * @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
  *
@@ -34,7 +34,7 @@ class Bzip2Compressor extends BaseFrameworkSystem implements Compressor {
         *
         * @return      void
         */
-       protected function __construct () {
+       private function __construct () {
                // Call parent constructor!
                parent::__construct(__CLASS__);
        }
@@ -49,10 +49,10 @@ class Bzip2Compressor extends BaseFrameworkSystem implements Compressor {
                $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;
@@ -63,16 +63,13 @@ class Bzip2Compressor extends BaseFrameworkSystem implements Compressor {
         *
         * @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;
        }
 
        /**
@@ -80,14 +77,8 @@ class Bzip2Compressor extends BaseFrameworkSystem implements Compressor {
         *
         * @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);