3 namespace Org\Mxchange\CoreFramework\Compressor\Null;
5 // Import framework stuff
6 use Org\Mxchange\CoreFramework\Compressor\Compressor;
7 use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
10 use \InvalidArgumentException;
13 * Null compression and decompression class
15 * @author Roland Haeder <webmaster@shipsimu.org>
17 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
18 * @license GNU GPL 3.0 or any newer version
19 * @link http://www.shipsimu.org
21 * This program is free software: you can redistribute it and/or modify
22 * it under the terms of the GNU General Public License as published by
23 * the Free Software Foundation, either version 3 of the License, or
24 * (at your option) any later version.
26 * This program is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 * GNU General Public License for more details.
31 * You should have received a copy of the GNU General Public License
32 * along with this program. If not, see <http://www.gnu.org/licenses/>.
34 class NullCompressor extends BaseFrameworkSystem implements Compressor {
36 * Protected constructor
40 private function __construct () {
41 // Call parent constructor!
42 parent::__construct(__CLASS__);
46 * Create a new compressor channel based a given compression handler
48 * @return $compressorInstance An instance of this class
50 public static final function createNullCompressor () {
52 $compressorInstance = new NullCompressor();
54 // Return the compressor instance
55 return $compressorInstance;
59 * Null compression stream
61 * @param $streamData Mixed non-object stream data
62 * @return $streamData The compressed stream data
63 * @throws InvalidArgumentException If the stream is not compressable or decompressable
65 public function compressStream (string $streamData) {
67 if (is_object($streamData) || is_resource($streamData)) {
69 throw new InvalidArgumentException(sprintf('streamData[]=%s cannot be compressed/decompressed', gettype($streamData)));
72 // Return the compressed stream
77 * Null decompression stream
79 * @param $streamData Mixed non-object stream data
80 * @return $streamData The decompressed stream data
81 * @throws InvalidArgumentException If the stream is not compressable or decompressable
83 public function decompressStream (string $streamData) {
85 if (is_object($streamData) || is_resource($streamData)) {
87 throw new InvalidArgumentException(sprintf('streamData[]=%s cannot be compressed/decompressed', gettype($streamData)));
90 // Return the decompressed stream
95 * Getter for the file extension of this compressor
97 * @return $string Returns always 'null'
99 public final function getCompressorExtension () {