]> git.mxchange.org Git - hub.git/blob - application/hub/main/compressor/decorator/class_NetworkPackageCompressorDecorator.php
State pattern added, hub continued (sorry, I let it lay around uncommitted for long...
[hub.git] / application / hub / main / compressor / decorator / class_NetworkPackageCompressorDecorator.php
1 <?php
2 /**
3  * A NetworkPackageCompressor decorator class. This decorator can later be
4  * easily extended without changing any other code.
5  *
6  * @author              Roland Haeder <webmaster@ship-simu.org>
7  * @version             0.0.0
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
11  *
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.
16  *
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.
21  *
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/>.
24  */
25 class NetworkPackageCompressorDecorator extends BaseFrameworkSystem implements Compressor {
26         /**
27          * Protected constructor
28          *
29          * @return      void
30          */
31         protected function __construct () {
32                 // Call parent constructor
33                 parent::__construct(__CLASS__);
34         }
35
36         /**
37          * Creates an instance of this class
38          *
39          * @return      $innerCompressorInstance        The inner Compressor class
40          * @return      $compressorInstance             An instance of a Compressor class
41          */
42         public final static function createNetworkPackageCompressorDecorator (Compressor $innerCompressorInstance) {
43                 // Get new instance
44                 $compressorInstance = new NetworkPackageCompressorDecorator();
45
46                 // Set the inner compressor class
47                 $compressorInstance->setCompressorInstance($innerCompressorInstance);
48
49                 // Return the prepared instance
50                 return $compressorInstance;
51         }
52
53         /**
54          * A compression stream
55          *
56          * @param       $streamData             Mixed non-object stream data
57          * @return      $streamData             The compressed stream data
58          * @throws      InvalidObjectException  If the stream is an object
59          */
60         public function compressStream ($streamData) {
61                 // Call the inner compressor class
62                 return $this->getCompressorInstance()->compressStream($streamData);
63         }
64
65         /**
66          * A decompression stream
67          *
68          * @param       $streamData             Mixed non-object stream data
69          * @return      $streamData             The decompressed stream data
70          * @throws      InvalidObjectException  If the stream is an object
71          */
72         public function decompressStream ($streamData) {
73                 // Call the inner compressor class
74                 return $this->getCompressorInstance()->decompressStream($streamData);
75         }
76
77         /**
78          * Getter for the file extension of this compressor
79          *
80          * @return      $string The compressor's file extension
81          */
82         public function getCompressorExtension () {
83                 // Call the inner compressor class
84                 return $this->getCompressorInstance()->getCompressorExtension();
85         }
86 }
87
88 // [EOF]
89 ?>