]> git.mxchange.org Git - core.git/blobdiff - framework/main/classes/compressor/class_NullCompressor.php
Continued:
[core.git] / framework / main / classes / compressor / class_NullCompressor.php
index 3bc22cc8049fdb735285dd2f8fb2607f7aee7b1f..e3d2af01b566f454a5a72c41e9d5faa2b453d5c1 100644 (file)
@@ -6,12 +6,15 @@ namespace Org\Mxchange\CoreFramework\Compressor\Null;
 use Org\Mxchange\CoreFramework\Compressor\Compressor;
 use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
 
+// Load SPL stuff
+use \InvalidArgumentException;
+
 /**
  * Null compression and decompression class
  *
  * @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 +37,7 @@ class NullCompressor extends BaseFrameworkSystem implements Compressor {
         *
         * @return      void
         */
-       protected function __construct () {
+       private function __construct () {
                // Call parent constructor!
                parent::__construct(__CLASS__);
        }
@@ -57,13 +60,14 @@ class NullCompressor 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
+        * @throws      InvalidArgumentException        If the stream is not compressable or decompressable
         */
-       public function compressStream ($streamData) {
-               if (is_object($streamData)) {
+       public function compressStream (string $streamData) {
+               // Validate parameter
+               if (is_object($streamData) || is_resource($streamData)) {
                        // Throw an exception
-                       throw new InvalidObjectException($streamData, self::EXCEPTION_UNEXPECTED_OBJECT);
-               } // END - if
+                       throw new InvalidArgumentException(sprintf('streamData[]=%s cannot be compressed/decompressed', gettype($streamData)));
+               }
 
                // Return the compressed stream
                return $streamData;
@@ -74,13 +78,14 @@ class NullCompressor 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
+        * @throws      InvalidArgumentException        If the stream is not compressable or decompressable
         */
-       public function decompressStream ($streamData) {
-               if (is_object($streamData)) {
+       public function decompressStream (string $streamData) {
+               // Validate parameter
+               if (is_object($streamData) || is_resource($streamData)) {
                        // Throw an exception
-                       throw new InvalidObjectException($streamData, self::EXCEPTION_UNEXPECTED_OBJECT);
-               } // END - if
+                       throw new InvalidArgumentException(sprintf('streamData[]=%s cannot be compressed/decompressed', gettype($streamData)));
+               }
 
                // Return the decompressed stream
                return $streamData;