From: Roland Häder Date: Sat, 12 Mar 2011 00:07:02 +0000 (+0000) Subject: Rewritten static 'create' method in all compressors, some code-cleanup X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=664da2f2a33949d1c60f3c8d47dd120701a0dae5;p=core.git Rewritten static 'create' method in all compressors, some code-cleanup --- diff --git a/inc/classes/main/compressor/class_Bzip2Compressor.php b/inc/classes/main/compressor/class_Bzip2Compressor.php index 665bfb4e..1b3824f8 100644 --- a/inc/classes/main/compressor/class_Bzip2Compressor.php +++ b/inc/classes/main/compressor/class_Bzip2Compressor.php @@ -35,20 +35,20 @@ class Bzip2Compressor extends BaseFrameworkSystem implements Compressor { /** * Create a new compressor channel based a given compression handler * - * @return $cInstance An instance of this class + * @return $compressorInstance An instance of this class */ public static final function createBzip2Compressor () { + // Routines not found by default + $compressorInstance = null; + // Get new instance if ((function_exists('bzcompress')) && (function_exists('bzdecompress'))) { // Compressor can maybe be used - $cInstance = new Bzip2Compressor(); - } else { - // Routines not found! - $cInstance = null; - } + $compressorInstance = new Bzip2Compressor(); + } // END - if // Return the compressor instance - return $cInstance; + return $compressorInstance; } /** @@ -62,7 +62,7 @@ class Bzip2Compressor extends BaseFrameworkSystem implements Compressor { if (is_object($streamData)) { // Throw an exception throw new InvalidObjectException($streamData, self::EXCEPTION_UNEXPECTED_OBJECT); - } + } // END - if // Return the compressed stream return bzcompress($streamData, 1); @@ -79,7 +79,7 @@ class Bzip2Compressor extends BaseFrameworkSystem implements Compressor { if (is_object($streamData)) { // Throw an exception throw new InvalidObjectException($streamData, self::EXCEPTION_UNEXPECTED_OBJECT); - } + } // END - if // Return the decompressed stream return bzdecompress($streamData); @@ -91,7 +91,7 @@ class Bzip2Compressor extends BaseFrameworkSystem implements Compressor { * @return $string Returns always "bz2" */ public final function getCompressorExtension () { - return "bz2"; + return 'bz2'; } } diff --git a/inc/classes/main/compressor/class_GzipCompressor.php b/inc/classes/main/compressor/class_GzipCompressor.php index 87894bd8..f69f4260 100644 --- a/inc/classes/main/compressor/class_GzipCompressor.php +++ b/inc/classes/main/compressor/class_GzipCompressor.php @@ -35,20 +35,20 @@ class GzipCompressor extends BaseFrameworkSystem implements Compressor { /** * Create a new compressor channel based a given compression handler * - * @return $cInstance An instance of this class + * @return $compressorInstance An instance of this class */ public static final function createGzipCompressor () { + // Routines not found by default + $compressorInstance = null; + // Get new instance if ((function_exists('gzcompress')) && (function_exists('gzuncompress'))) { // Compressor can maybe be used - $cInstance = new GzipCompressor(); - } else { - // Routines not found! - $cInstance = null; - } + $compressorInstance = new GzipCompressor(); + } // END - if // Return the compressor instance - return $cInstance; + return $compressorInstance; } /** @@ -62,7 +62,7 @@ class GzipCompressor extends BaseFrameworkSystem implements Compressor { if (is_object($streamData)) { // Throw an exception throw new InvalidObjectException($streamData, self::EXCEPTION_UNEXPECTED_OBJECT); - } + } // END - if // Return the compressed stream return gzcompress($streamData, 1); @@ -79,7 +79,7 @@ class GzipCompressor extends BaseFrameworkSystem implements Compressor { if (is_object($streamData)) { // Throw an exception throw new InvalidObjectException($streamData, self::EXCEPTION_UNEXPECTED_OBJECT); - } + } // END - if // Return the decompressed stream return gzuncompress($streamData); diff --git a/inc/classes/main/compressor/class_NullCompressor.php b/inc/classes/main/compressor/class_NullCompressor.php index 36f96d93..c03b5a39 100644 --- a/inc/classes/main/compressor/class_NullCompressor.php +++ b/inc/classes/main/compressor/class_NullCompressor.php @@ -35,14 +35,14 @@ class NullCompressor extends BaseFrameworkSystem implements Compressor { /** * Create a new compressor channel based a given compression handler * - * @return $cInstance An instance of this class + * @return $compressorInstance An instance of this class */ public static final function createNullCompressor () { // Get new instance - $cInstance = new NullCompressor(); + $compressorInstance = new NullCompressor(); // Return the compressor instance - return $cInstance; + return $compressorInstance; } /** @@ -56,7 +56,7 @@ class NullCompressor extends BaseFrameworkSystem implements Compressor { if (is_object($streamData)) { // Throw an exception throw new InvalidObjectException($streamData, self::EXCEPTION_UNEXPECTED_OBJECT); - } + } // END - if // Return the compressed stream return $streamData; @@ -73,7 +73,7 @@ class NullCompressor extends BaseFrameworkSystem implements Compressor { if (is_object($streamData)) { // Throw an exception throw new InvalidObjectException($streamData, self::EXCEPTION_UNEXPECTED_OBJECT); - } + } // END - if // Return the decompressed stream return $streamData; @@ -85,7 +85,7 @@ class NullCompressor extends BaseFrameworkSystem implements Compressor { * @return $string Returns always "null" */ public final function getCompressorExtension () { - return "null"; + return 'null'; } }