3 * A NetworkPackageCompressor decorator class. This decorator can later be
4 * easily extended without changing any other code.
6 * @author Roland Haeder <webmaster@ship-simu.org>
8 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009, 2010 Hub Developer Team
9 * @license GNU GPL 3.0 or any newer version
10 * @link http://www.ship-simu.org
12 * This program is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation, either version 3 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 class NetworkPackageCompressorDecorator extends BaseFrameworkSystem implements Compressor {
27 * Protected constructor
31 protected function __construct () {
32 // Call parent constructor
33 parent::__construct(__CLASS__);
37 * Creates an instance of this class
39 * @return $innerCompressorInstance The inner Compressor class
40 * @return $compressorInstance An instance of a Compressor class
42 public static final function createNetworkPackageCompressorDecorator (Compressor $innerCompressorInstance) {
44 $compressorInstance = new NetworkPackageCompressorDecorator();
46 // Set the inner compressor class
47 $compressorInstance->setCompressorInstance($innerCompressorInstance);
49 // Return the prepared instance
50 return $compressorInstance;
54 * A compression stream
56 * @param $streamData Mixed non-object stream data
57 * @return $streamData The compressed stream data
58 * @throws InvalidObjectException If the stream is an object
60 public function compressStream ($streamData) {
61 // Call the inner compressor class
62 return $this->getCompressorInstance()->compressStream($streamData);
66 * A decompression stream
68 * @param $streamData Mixed non-object stream data
69 * @return $streamData The decompressed stream data
70 * @throws InvalidObjectException If the stream is an object
72 public function decompressStream ($streamData) {
73 // Call the inner compressor class
74 return $this->getCompressorInstance()->decompressStream($streamData);
78 * Getter for the file extension of this compressor
80 * @return $string The compressor's file extension
82 public function getCompressorExtension () {
83 // Call the inner compressor class
84 return $this->getCompressorInstance()->getCompressorExtension();