class_GzipCompressor.php

Go to the documentation of this file.
00001 <?php
00024 class GzipCompressor extends BaseFrameworkSystem implements Compressor {
00030         protected function __construct () {
00031                 // Call parent constructor!
00032                 parent::__construct(__CLASS__);
00033         }
00034 
00040         public final static function createGzipCompressor () {
00041                 // Get new instance
00042                 if ((function_exists('gzcompress')) && (function_exists('gzuncompress'))) {
00043                         // Compressor can maybe be used
00044                         $cInstance = new GzipCompressor();
00045                 } else {
00046                         // Routines not found!
00047                         $cInstance = null;
00048                 }
00049 
00050                 // Return the compressor instance
00051                 return $cInstance;
00052         }
00053 
00061         public function compressStream ($streamData) {
00062                 if (is_object($streamData)) {
00063                         // Throw an exception
00064                         throw new InvalidObjectException($streamData, self::EXCEPTION_UNEXPECTED_OBJECT);
00065                 }
00066 
00067                 // Return the compressed stream
00068                 return gzcompress($streamData, 1);
00069         }
00070 
00078         public function decompressStream ($streamData) {
00079                 if (is_object($streamData)) {
00080                         // Throw an exception
00081                         throw new InvalidObjectException($streamData, self::EXCEPTION_UNEXPECTED_OBJECT);
00082                 }
00083 
00084                 // Return the decompressed stream
00085                 return gzuncompress($streamData);
00086         }
00087 
00093         public final function getCompressorExtension () {
00094                 return "gz";
00095         }
00096 }
00097 
00098 // [EOF]
00099 ?>

Generated on Mon Dec 8 01:06:45 2008 for Ship-Simulator by  doxygen 1.5.6