]> 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 a18a1a816d0c51d5e32c31f905f652fc9465f1b5..79e865dd95bc1ad031c6718d7f14a5d4084d76ff 100644 (file)
@@ -6,6 +6,9 @@ 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
  *
@@ -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)) {
+               // 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)) {
+               // 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;