use Org\Mxchange\CoreFramework\Compressor\Compressor;
use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
+// Load SPL stuff
+use \InvalidArgumentException;
+
/**
* BZIP2 compression and decompression class
*
if ((function_exists('bzcompress')) && (function_exists('bzdecompress'))) {
// Compressor can maybe be used
$compressorInstance = new Bzip2Compressor();
- } // END - if
+ }
// Return the compressor instance
return $compressorInstance;
*
* @param $streamData Mixed non-object stream data
* @return $streamData The compressed stream data
- * @throws InvalidObjectException If the stream is an object
+ * @throws InvalidArgumentException If the stream is not compressable or decompressable
*/
public function compressStream ($streamData) {
- if (is_object($streamData)) {
+ // Validate parameter
+ if (is_object($streamData) || is_resource($streamData)) {
// Throw an exception
- throw new InvalidObjectException($streamData, self::EXCEPTION_UNEXPECTED_OBJECT);
- } // END - if
+ throw new InvalidArgumentException(sprintf('streamData[]=%s cannot be compressed/decompressed', gettype($streamData)));
+ }
// Return the compressed stream
return bzcompress($streamData, 1);
*
* @param $streamData Mixed non-object stream data
* @return $streamData The decompressed stream data
- * @throws InvalidObjectException If the stream is an object
+ * @throws InvalidArgumentException If the stream is not compressable or decompressable
*/
public function decompressStream ($streamData) {
- if (is_object($streamData)) {
+ // Validate parameter
+ if (is_object($streamData) || is_resource($streamData)) {
// Throw an exception
- throw new InvalidObjectException($streamData, self::EXCEPTION_UNEXPECTED_OBJECT);
- } // END - if
+ throw new InvalidArgumentException(sprintf('streamData[]=%s cannot be compressed/decompressed', gettype($streamData)));
+ }
// Decompress it
$streamData = bzdecompress($streamData, true);
use Org\Mxchange\CoreFramework\Compressor\Compressor;
use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
+// Load SPL stuff
+use \InvalidArgumentException;
+
/**
* GZIP compression and decompression class
*
if ((function_exists('gzencode')) && (function_exists('gzdecode'))) {
// Compressor can maybe be used
$compressorInstance = new GzipCompressor();
- } // END - if
+ }
// Return the compressor instance
return $compressorInstance;
*
* @param $streamData Mixed non-object stream data
* @return $streamData The compressed stream data
- * @throws InvalidObjectException If the stream is an object
+ * @throws InvalidArgumentException If the stream is not compressable or decompressable
*/
public function compressStream ($streamData) {
- if (is_object($streamData)) {
+ // Validate parameter
+ if (is_object($streamData) || is_resource($streamData)) {
// Throw an exception
- throw new InvalidObjectException($streamData, self::EXCEPTION_UNEXPECTED_OBJECT);
- } // END - if
+ throw new InvalidArgumentException(sprintf('streamData[]=%s cannot be compressed/decompressed', gettype($streamData)));
+ }
// Return the compressed stream
return gzencode($streamData, 1);
*
* @param $streamData Mixed non-object stream data
* @return $streamData The decompressed stream data
- * @throws InvalidObjectException If the stream is an object
+ * @throws InvalidArgumentException If the stream is not compressable or decompressable
*/
public function decompressStream ($streamData) {
- if (is_object($streamData)) {
+ // Validate parameter
+ if (is_object($streamData) || is_resource($streamData)) {
// Throw an exception
- throw new InvalidObjectException($streamData, self::EXCEPTION_UNEXPECTED_OBJECT);
- } // END - if
+ throw new InvalidArgumentException(sprintf('streamData[]=%s cannot be compressed/decompressed', gettype($streamData)));
+ }
// Return the decompressed stream
return gzdecode($streamData);
use Org\Mxchange\CoreFramework\Compressor\Compressor;
use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
+// Load SPL stuff
+use \InvalidArgumentException;
+
/**
* Null compression and decompression class
*
*
* @param $streamData Mixed non-object stream data
* @return $streamData The compressed stream data
- * @throws InvalidObjectException If the stream is an object
+ * @throws InvalidArgumentException If the stream is not compressable or decompressable
*/
public function compressStream ($streamData) {
- if (is_object($streamData)) {
+ // Validate parameter
+ if (is_object($streamData) || is_resource($streamData)) {
// Throw an exception
- throw new InvalidObjectException($streamData, self::EXCEPTION_UNEXPECTED_OBJECT);
- } // END - if
+ throw new InvalidArgumentException(sprintf('streamData[]=%s cannot be compressed/decompressed', gettype($streamData)));
+ }
// Return the compressed stream
return $streamData;
*
* @param $streamData Mixed non-object stream data
* @return $streamData The decompressed stream data
- * @throws InvalidObjectException If the stream is an object
+ * @throws InvalidArgumentException If the stream is not compressable or decompressable
*/
public function decompressStream ($streamData) {
- if (is_object($streamData)) {
+ // Validate parameter
+ if (is_object($streamData) || is_resource($streamData)) {
// Throw an exception
- throw new InvalidObjectException($streamData, self::EXCEPTION_UNEXPECTED_OBJECT);
- } // END - if
+ throw new InvalidArgumentException(sprintf('streamData[]=%s cannot be compressed/decompressed', gettype($streamData)));
+ }
// Return the decompressed stream
return $streamData;
use Org\Mxchange\CoreFramework\Compressor\Compressor;
use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
+// Load SPL stuff
+use \InvalidArgumentException;
+
/**
* ZLIB compression and decompression class
*
if ((function_exists('gzcompress')) && (function_exists('gzuncompress'))) {
// Compressor can maybe be used
$compressorInstance = new ZlibCompressor();
- } // END - if
+ }
// Return the compressor instance
return $compressorInstance;
*
* @param $streamData Mixed non-object stream data
* @return $streamData The compressed stream data
- * @throws InvalidObjectException If the stream is an object
+ * @throws InvalidArgumentException If the stream is not compressable or decompressable
*/
public function compressStream ($streamData) {
- if (is_object($streamData)) {
+ // Validate parameter
+ if (is_object($streamData) || is_resource($streamData)) {
// Throw an exception
- throw new InvalidObjectException($streamData, self::EXCEPTION_UNEXPECTED_OBJECT);
- } // END - if
+ throw new InvalidArgumentException(sprintf('streamData[]=%s cannot be compressed/decompressed', gettype($streamData)));
+ }
// Return the compressed stream
return gzcompress($streamData, 1);
*
* @param $streamData Mixed non-object stream data
* @return $streamData The decompressed stream data
- * @throws InvalidObjectException If the stream is an object
+ * @throws InvalidArgumentException If the stream is not compressable or decompressable
*/
public function decompressStream ($streamData) {
- if (is_object($streamData)) {
+ // Validate parameter
+ if (is_object($streamData) || is_resource($streamData)) {
// Throw an exception
- throw new InvalidObjectException($streamData, self::EXCEPTION_UNEXPECTED_OBJECT);
- } // END - if
+ throw new InvalidArgumentException(sprintf('streamData[]=%s cannot be compressed/decompressed', gettype($streamData)));
+ }
// Return the decompressed stream
return gzuncompress($streamData);
* @param $filterChain Name of the filter chain
* @return void
*/
- protected function initFilterChain ($filterChain) {
+ protected function initFilterChain (string $filterChain) {
//* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONTROLLER: ' . $filterChain . ' init: START');
$this->filterChains[$filterChain] = ObjectFactory::createObjectByConfiguredName('filter_chain_class');
//* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONTROLLER: ' . $filterChain . ' init: FINISHED');
* @return void
* @throws InvalidFilterChainException If the filter chain is invalid
*/
- protected function addFilter ($filterChain, Filterable $filterInstance) {
+ protected function addFilter (string $filterChain, Filterable $filterInstance) {
//* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONTROLLER: ' . $filterChain . ',' . $filterInstance->__toString(). ' add: START');
// Test if the filter is there
* @return void
* @throws InvalidFilterChainException If the filter chain is invalid
*/
- protected function executeFilters ($filterChain, Requestable $requestInstance, Responseable $responseInstance) {
+ protected function executeFilters (string $filterChain, Requestable $requestInstance, Responseable $responseInstance) {
// Test if the filter is there
if (!isset($this->filterChains[$filterChain])) {
// Throw an exception here
/**
* Protected constructor
*
+ * @param $className Name of the class
* @return void
*/
- protected function __construct ($class) {
+ protected function __construct (string $className) {
// Call parent constructor
- parent::__construct($class);
+ parent::__construct($className);
// Initialize the cache instance
$this->initCacheInstance();
+++ /dev/null
-<?php
-// Own namespace
-namespace Org\Mxchange\CoreFramework\Template\Xml;
-
-// Import framework stuff
-use Org\Mxchange\CoreFramework\Generic\BaseDecorator;
-use Org\Mxchange\CoreFramework\Response\Responseable;
-use Org\Mxchange\CoreFramework\Template\Xml\CompileableXmlTemplate;
-use Org\Mxchange\CoreFramework\Traits\Template\CompileableTemplateTrait;
-
-/**
- * A decorator for XML template engines which rewrites the XML for compacting
- * it.
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class XmlRewriterTemplateDecorator extends BaseDecorator implements CompileableXmlTemplate {
- // Load traits
- use CompileableTemplateTrait;
-
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of the class TemplateEngine and prepares it for usage
- *
- * @param $innerTemplateInstance A CompileableXmlTemplate instance
- * @return $templateInstance An instance of TemplateEngine
- */
- public static final function createXmlRewriterTemplateDecorator (CompileableXmlTemplate $innerTemplateInstance) {
- // Get a new instance
- $templateInstance = new XmlRewriterTemplateDecorator();
-
- // Set the inner template engine
- $templateInstance->setTemplateInstance($innerTemplateInstance);
-
- // Return the prepared instance
- return $templateInstance;
- }
-
- /**
- * Settter for variable group
- *
- * @param $groupName Name of variable group
- * @param $add Whether add this group
- * @return void
- */
- public function setVariableGroup (string $groupName, bool $add = true) {
- // Call the inner class' method
- $this->getTemplateInstance()->setVariableGroup($groupName, $add);
- }
-
- /**
- * Adds a variable to current group
- *
- * @param $variableName Variable to set
- * @param $value Value to store in variable
- * @return void
- */
- public function addGroupVariable (string $variableName, $value) {
- // Call the inner class' method
- $this->getTemplateInstance()->addGroupVariable($variableName, $value);
- }
-
- /**
- * Getter for base path
- *
- * @return $templateBasePath The relative base path for all templates
- */
- public final function getTemplateBasePath () {
- // Call the inner class' method
- return $this->getTemplateInstance()->getTemplateBasePath();
- }
-
- /**
- * Getter for generic base path
- *
- * @return $templateBasePath The relative base path for all templates
- */
- public final function getGenericBasePath () {
- // Call the inner class' method
- return $this->getTemplateInstance()->getGenericBasePath();
- }
-
- /**
- * Getter for template extension
- *
- * @return $templateExtension The file extension for all uncompiled templates
- */
- public final function getRawTemplateExtension () {
- // Call the inner class' method
- return $this->getTemplateInstance()->getRawTemplateExtension();
- }
-
- /**
- * Getter for given variable group
- *
- * @param $variableGroup Variable group to check
- * @return $varStack Found variable group
- */
- public function getVarStack (string $variableGroup) {
- // Call the inner class' method
- return $this->getTemplateInstance()->getVarStack($variableGroup);
- }
-
- /**
- * Getter for code-template extension
- *
- * @return $codeExtension The file extension for all code templates
- */
- public final function getCodeTemplateExtension () {
- // Call the inner class' method
- return $this->getTemplateInstance()->getCodeTemplateExtension();
- }
-
- /**
- * Getter for template type
- *
- * @return $templateType The current template's type
- */
- public final function getTemplateType () {
- // Call the inner class' method
- return $this->getTemplateInstance()->getTemplateType();
- }
-
- /**
- * Assign (add) a given variable with a value
- *
- * @param $variableName The variable we are looking for
- * @param $value The value we want to store in the variable
- * @return void
- */
- public function assignVariable (string $variableName, $value) {
- // Call the inner class' method
- $this->getTemplateInstance()->assignVariable($variableName, $value);
- }
-
- /**
- * Removes a given variable
- *
- * @param $variableName The variable we are looking for
- * @param $variableGroup Name of variable group (default: 'general')
- * @return void
- */
- public function removeVariable (string $variableName, string $variableGroup = 'general') {
- // Call the inner class' method
- $this->getTemplateInstance()->removeVariable($variableName, $variableGroup);
- }
-
- /**
- * Load a specified HTML template into the engine
- *
- * @param $template The web template we shall load which is located in
- * 'html' by default
- * @return void
- */
- public function loadHtmlTemplate (string $template) {
- // Call the inner class' method
- $this->getTemplateInstance()->loadHtmlTemplate($template);
- }
-
- /**
- * Assign a given congfiguration variable with a value
- *
- * @param $variableName The configuration variable we want to assign
- * @return void
- */
- public function assignConfigVariable (string $variableName) {
- // Call the inner class' method
- $this->getTemplateInstance()->assignConfigVariable($variableName);
- }
-
- /**
- * Load a specified code template into the engine
- *
- * @param $template The code template we shall load which is
- * located in 'code' by default
- * @return void
- */
- public function loadCodeTemplate (string $template) {
- // Call the inner class' method
- $this->getTemplateInstance()->loadCodeTemplate($template);
- }
-
- /**
- * Load a specified email template into the engine for later compilation
- * with other code/web/email templates.
- *
- * @param $template The email template we shall load which is
- * located in "html" by default
- * @return void
- */
- public function loadEmailTemplate ($template) {
- // Call the inner class' method
- $this->getTemplateInstance()->loadEmailTemplate($template);
- }
-
- /**
- * Compiles configuration place-holders in all variables. This 'walks'
- * through the variable stack 'general'. It interprets all values from that
- * variables as configuration entries after compiling them.
- *
- * @return void
- */
- public function compileConfigInVariables () {
- // Call the inner class' method
- $this->getTemplateInstance()->compileConfigInVariables();
- }
-
- /**
- * Compile all variables by inserting their respective values
- *
- * @return void
- */
- public function compileVariables () {
- // Call the inner class' method
- $this->getTemplateInstance()->compileVariables();
- }
-
- /**
- * Compile all required templates into the current loaded one
- *
- * @return void
- */
- public function compileTemplate () {
- // Call the inner class' method
- $this->getTemplateInstance()->compileTemplate();
- }
-
- /**
- * Assigns the last loaded raw template content with a given variable
- *
- * @param $templateName Name of the template we want to assign
- * @param $variableName Name of the variable we want to assign
- * @return void
- */
- public function assignTemplateWithVariable (string $templateName, string $variableName) {
- // Call the inner class' method
- $this->getTemplateInstance()->assignTemplateWithVariable($templateName, $variableName);
- }
-
- /**
- * Transfers the content of this template engine to a given response instance
- *
- * @param $responseInstance An instance of a Responseable class
- * @return void
- */
- public function transferToResponse (Responseable $responseInstance) {
- // Call the inner class' method
- $this->getTemplateInstance()->transportToResponse($responseInstance);
- }
-
- /**
- * Assigns all the application data with template variables
- *
- * @return void
- */
- public function assignApplicationData () {
- // Call the inner class' method
- $this->getTemplateInstance()->assignApplicationData();
- }
-
- /**
- * "Compiles" a variable by replacing {?var?} with it's content
- *
- * @param $rawCode Raw code to compile
- * @param $setMatchAsCode Sets $match if readVariable() returns empty result
- * @return $rawCode Compile code with inserted variable value
- */
- public function compileRawCode (string $rawCode, bool $setMatchAsCode = false) {
- return $this->getTemplateInstance()->compileRawCode($rawCode, $setMatchAsCode);
- }
-
- /**
- * Getter for variable group array
- *
- * @return $variableGroups All variable groups
- */
- public final function getVariableGroups () {
- // Call the inner class' method
- return $this->getTemplateInstance()->getVariableGroups();
- }
-
- /**
- * Getter for raw template data
- *
- * @return $rawTemplateData The raw data from the template
- */
- public function getRawTemplateData () {
- // Call the inner class' method
- return $this->getTemplateInstance()->getRawTemplateData();
- }
-
- /**
- * Renames a variable in code and in stack
- *
- * @param $oldName Old name of variable
- * @param $newName New name of variable
- * @return void
- */
- public function renameVariable (string $oldName, string $newName) {
- // Call the inner class' method
- $this->getTemplateInstance()->renameVariable($oldName, $newName);
- }
-
- /**
- * Renders the given XML content
- *
- * @param $content Valid XML content or if not set the current loaded raw content
- * @return void
- * @throws XmlParserException If an XML error was found
- */
- public function renderXmlContent (string $content = NULL) {
- // Call the inner class' method
- $this->getTemplateInstance()->renderXmlContent($content);
- }
-
- /**
- * Enables or disables language support
- *
- * @param $languageSupport New language support setting
- * @return void
- */
- public function enableLanguageSupport (bool $languageSupport = true) {
- // Call the inner class' method
- $this->getTemplateInstance()->enableLanguageSupport($languageSupport);
- }
-
- /**
- * Checks whether language support is enabled
- *
- * @return $languageSupport Whether language support is enabled or disabled
- */
- public function isLanguageSupportEnabled () {
- // Call the inner class' method
- return $this->getTemplateInstance()->isLanguageSupportEnabled();
- }
-
- /**
- * Enables or disables XML compacting
- *
- * @param $xmlCompacting New XML compacting setting
- * @return void
- */
- public function enableXmlCompacting (bool $xmlCompacting = true) {
- // Call the inner class' method
- $this->getTemplateInstance()->enableXmlCompacting($xmlCompacting);
- }
-
- /**
- * Checks whether XML compacting is enabled
- *
- * @return $xmlCompacting Whether XML compacting is enabled or disabled
- */
- public function isXmlCompactingEnabled () {
- // Call the inner class' method
- return $this->getTemplateInstance()->isXmlCompactingEnabled();
- }
-
- /**
- * Handles the start element of an XML resource
- *
- * @param $resource XML parser resource (currently ignored)
- * @param $element The element we shall handle
- * @param $attributes All attributes
- * @return void
- * @throws InvalidXmlNodeException If an unknown/invalid XML node name was found
- */
- public function startElement ($resource, string $element, array $attributes) {
- // Call the inner class' method
- $this->getTemplateInstance()->startElement($resource, $element, $attributes);
- }
-
- /**
- * Ends the main or sub node by sending out the gathered data
- *
- * @param $resource An XML resource pointer (currently ignored)
- * @param $nodeName Name of the node we want to finish
- * @return void
- * @throws XmlNodeMismatchException If current main node mismatches the closing one
- */
- public function finishElement ($resource, string $nodeName) {
- // Call the inner class' method
- $this->getTemplateInstance()->finishElement($resource, $nodeName);
- }
-
- /**
- * Currently not used
- *
- * @param $resource XML parser resource (currently ignored)
- * @param $characters Characters to handle
- * @return void
- * @todo Find something useful with this!
- */
- public function characterHandler ($resource, string $characters) {
- // Call the inner class' method but trim the characters before
- $this->getTemplateInstance()->characterHandler($resource, trim($characters));
- }
-
- /**
- * Removes all comments, tabs and new-line charcters to compact the content
- *
- * @param $uncompactedContent The uncompacted content
- * @return $compactedContent The compacted content
- */
- public function compactContent (string $uncompactedContent) {
- // Compact it ...
- $compactedContent = $this->getTemplateInstance()->compactContent($uncompactedContent);
-
- // ... and return it
- return $compactedContent;
- }
-
- /**
- * Assigns a lot variables into the stack of currently loaded template.
- * This method should only be used in very rare circumstances, e.g. when
- * you have to copy a whole set of variables into the template engine.
- * Before you use this method, please make sure you have considered all
- * other possiblities.
- *
- * @param $variables An array with variables to be assigned
- * @return void
- */
- public function assignMultipleVariables (array $variables) {
- // Call the inner class' method but trim the characters before
- $this->getTemplateInstance()->assignMultipleVariables($variables);
- }
-
-}
+++ /dev/null
-<?php
-// Own namespace
-namespace Org\Mxchange\CoreFramework\Parser\Xml;
-
-// Import framework stuff
-use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
-use Org\Mxchange\CoreFramework\Generic\BaseDecorator;
-use Org\Mxchange\CoreFramework\Parser\Parseable;
-
-/**
- * A XML compacting decorator class for XML parsers
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class XmlCompactorDecorator extends BaseDecorator implements Parseable {
- /**
- * Instance of the parser class
- */
- private $parserInstance = NULL;
-
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of the class Parser and prepares it for usage
- *
- * @param $innerParserInstance A Parseable instance
- * @return $parserInstance An instance of this parser
- */
- public static final function createXmlCompactorDecorator (Parseable $innerParserInstance) {
- // Get a new instance
- $parserInstance = new XmlCompactorDecorator();
-
- // Get a new decorator instance for the template engine
- $templateInstance = ObjectFactory::createObjectByConfiguredName('deco_xml_rewriter_template_class', array($innerParserInstance->getTemplateInstance()));
-
- // Re-set the parser's template instance to the decorator instance
- $innerParserInstance->setTemplateInstance($templateInstance);
-
- // Set the inner parser instance
- $parserInstance->setParserInstance($innerParserInstance);
-
- // Return the prepared instance
- return $parserInstance;
- }
-
- /**
- * Setter for Parseable instance
- *
- * @param $parserInstance An instance of an Parseable
- * @return void
- */
- protected final function setParserInstance (Parseable $parserInstance) {
- $this->parserInstance = $parserInstance;
- }
-
- /**
- * Getter for Parseable instance
- *
- * @return $parserInstance An instance of an Parseable
- */
- private final function getParserInstance () {
- return $this->parserInstance;
- }
-
- /**
- * Parses the given XML content
- *
- * @param $content Valid XML content
- * @return void
- * @throws XmlCompactorDecoratorException If an XML error was found
- */
- public function parseXmlContent ($content) {
- // Remove all comments for better compacting
- $content = $this->getParserInstance()->getTemplateInstance()->compactContent($content);
-
- // Parse the content
- $this->getParserInstance()->parseXmlContent($content);
- }
-
-}
--- /dev/null
+<?php
+// Own namespace
+namespace Org\Mxchange\CoreFramework\Parser\Xml;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
+use Org\Mxchange\CoreFramework\Generic\BaseDecorator;
+use Org\Mxchange\CoreFramework\Parser\Parseable;
+
+/**
+ * A XML compacting decorator class for XML parsers
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class XmlCompactorDecorator extends BaseDecorator implements Parseable {
+ /**
+ * Instance of the parser class
+ */
+ private $parserInstance = NULL;
+
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of the class Parser and prepares it for usage
+ *
+ * @param $innerParserInstance A Parseable instance
+ * @return $parserInstance An instance of this parser
+ */
+ public static final function createXmlCompactorDecorator (Parseable $innerParserInstance) {
+ // Get a new instance
+ $parserInstance = new XmlCompactorDecorator();
+
+ // Get a new decorator instance for the template engine
+ $templateInstance = ObjectFactory::createObjectByConfiguredName('deco_xml_rewriter_template_class', array($innerParserInstance->getTemplateInstance()));
+
+ // Re-set the parser's template instance to the decorator instance
+ $innerParserInstance->setTemplateInstance($templateInstance);
+
+ // Set the inner parser instance
+ $parserInstance->setParserInstance($innerParserInstance);
+
+ // Return the prepared instance
+ return $parserInstance;
+ }
+
+ /**
+ * Setter for Parseable instance
+ *
+ * @param $parserInstance An instance of an Parseable
+ * @return void
+ */
+ protected final function setParserInstance (Parseable $parserInstance) {
+ $this->parserInstance = $parserInstance;
+ }
+
+ /**
+ * Getter for Parseable instance
+ *
+ * @return $parserInstance An instance of an Parseable
+ */
+ private final function getParserInstance () {
+ return $this->parserInstance;
+ }
+
+ /**
+ * Parses the given XML content
+ *
+ * @param $content Valid XML content
+ * @return void
+ * @throws XmlCompactorDecoratorException If an XML error was found
+ */
+ public function parseXmlContent (string $content) {
+ // Remove all comments for better compacting
+ $content = $this->getParserInstance()->getTemplateInstance()->compactContent($content);
+
+ // Parse the content
+ $this->getParserInstance()->parseXmlContent($content);
+ }
+
+}
--- /dev/null
+<?php
+// Own namespace
+namespace Org\Mxchange\CoreFramework\Template\Xml;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Generic\BaseDecorator;
+use Org\Mxchange\CoreFramework\Response\Responseable;
+use Org\Mxchange\CoreFramework\Template\Xml\CompileableXmlTemplate;
+use Org\Mxchange\CoreFramework\Traits\Template\CompileableTemplateTrait;
+
+/**
+ * A decorator for XML template engines which rewrites the XML for compacting
+ * it.
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class XmlRewriterTemplateDecorator extends BaseDecorator implements CompileableXmlTemplate {
+ // Load traits
+ use CompileableTemplateTrait;
+
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of the class TemplateEngine and prepares it for usage
+ *
+ * @param $innerTemplateInstance A CompileableXmlTemplate instance
+ * @return $templateInstance An instance of TemplateEngine
+ */
+ public static final function createXmlRewriterTemplateDecorator (CompileableXmlTemplate $innerTemplateInstance) {
+ // Get a new instance
+ $templateInstance = new XmlRewriterTemplateDecorator();
+
+ // Set the inner template engine
+ $templateInstance->setTemplateInstance($innerTemplateInstance);
+
+ // Return the prepared instance
+ return $templateInstance;
+ }
+
+ /**
+ * Settter for variable group
+ *
+ * @param $groupName Name of variable group
+ * @param $add Whether add this group
+ * @return void
+ */
+ public function setVariableGroup (string $groupName, bool $add = true) {
+ // Call the inner class' method
+ $this->getTemplateInstance()->setVariableGroup($groupName, $add);
+ }
+
+ /**
+ * Adds a variable to current group
+ *
+ * @param $variableName Variable to set
+ * @param $value Value to store in variable
+ * @return void
+ */
+ public function addGroupVariable (string $variableName, $value) {
+ // Call the inner class' method
+ $this->getTemplateInstance()->addGroupVariable($variableName, $value);
+ }
+
+ /**
+ * Getter for base path
+ *
+ * @return $templateBasePath The relative base path for all templates
+ */
+ public final function getTemplateBasePath () {
+ // Call the inner class' method
+ return $this->getTemplateInstance()->getTemplateBasePath();
+ }
+
+ /**
+ * Getter for generic base path
+ *
+ * @return $templateBasePath The relative base path for all templates
+ */
+ public final function getGenericBasePath () {
+ // Call the inner class' method
+ return $this->getTemplateInstance()->getGenericBasePath();
+ }
+
+ /**
+ * Getter for template extension
+ *
+ * @return $templateExtension The file extension for all uncompiled templates
+ */
+ public final function getRawTemplateExtension () {
+ // Call the inner class' method
+ return $this->getTemplateInstance()->getRawTemplateExtension();
+ }
+
+ /**
+ * Getter for given variable group
+ *
+ * @param $variableGroup Variable group to check
+ * @return $varStack Found variable group
+ */
+ public function getVarStack (string $variableGroup) {
+ // Call the inner class' method
+ return $this->getTemplateInstance()->getVarStack($variableGroup);
+ }
+
+ /**
+ * Getter for code-template extension
+ *
+ * @return $codeExtension The file extension for all code templates
+ */
+ public final function getCodeTemplateExtension () {
+ // Call the inner class' method
+ return $this->getTemplateInstance()->getCodeTemplateExtension();
+ }
+
+ /**
+ * Getter for template type
+ *
+ * @return $templateType The current template's type
+ */
+ public final function getTemplateType () {
+ // Call the inner class' method
+ return $this->getTemplateInstance()->getTemplateType();
+ }
+
+ /**
+ * Assign (add) a given variable with a value
+ *
+ * @param $variableName The variable we are looking for
+ * @param $value The value we want to store in the variable
+ * @return void
+ */
+ public function assignVariable (string $variableName, $value) {
+ // Call the inner class' method
+ $this->getTemplateInstance()->assignVariable($variableName, $value);
+ }
+
+ /**
+ * Removes a given variable
+ *
+ * @param $variableName The variable we are looking for
+ * @param $variableGroup Name of variable group (default: 'general')
+ * @return void
+ */
+ public function removeVariable (string $variableName, string $variableGroup = 'general') {
+ // Call the inner class' method
+ $this->getTemplateInstance()->removeVariable($variableName, $variableGroup);
+ }
+
+ /**
+ * Load a specified HTML template into the engine
+ *
+ * @param $template The web template we shall load which is located in
+ * 'html' by default
+ * @return void
+ */
+ public function loadHtmlTemplate (string $template) {
+ // Call the inner class' method
+ $this->getTemplateInstance()->loadHtmlTemplate($template);
+ }
+
+ /**
+ * Assign a given congfiguration variable with a value
+ *
+ * @param $variableName The configuration variable we want to assign
+ * @return void
+ */
+ public function assignConfigVariable (string $variableName) {
+ // Call the inner class' method
+ $this->getTemplateInstance()->assignConfigVariable($variableName);
+ }
+
+ /**
+ * Load a specified code template into the engine
+ *
+ * @param $template The code template we shall load which is
+ * located in 'code' by default
+ * @return void
+ */
+ public function loadCodeTemplate (string $template) {
+ // Call the inner class' method
+ $this->getTemplateInstance()->loadCodeTemplate($template);
+ }
+
+ /**
+ * Load a specified email template into the engine for later compilation
+ * with other code/web/email templates.
+ *
+ * @param $template The email template we shall load which is
+ * located in "html" by default
+ * @return void
+ */
+ public function loadEmailTemplate ($template) {
+ // Call the inner class' method
+ $this->getTemplateInstance()->loadEmailTemplate($template);
+ }
+
+ /**
+ * Compiles configuration place-holders in all variables. This 'walks'
+ * through the variable stack 'general'. It interprets all values from that
+ * variables as configuration entries after compiling them.
+ *
+ * @return void
+ */
+ public function compileConfigInVariables () {
+ // Call the inner class' method
+ $this->getTemplateInstance()->compileConfigInVariables();
+ }
+
+ /**
+ * Compile all variables by inserting their respective values
+ *
+ * @return void
+ */
+ public function compileVariables () {
+ // Call the inner class' method
+ $this->getTemplateInstance()->compileVariables();
+ }
+
+ /**
+ * Compile all required templates into the current loaded one
+ *
+ * @return void
+ */
+ public function compileTemplate () {
+ // Call the inner class' method
+ $this->getTemplateInstance()->compileTemplate();
+ }
+
+ /**
+ * Assigns the last loaded raw template content with a given variable
+ *
+ * @param $templateName Name of the template we want to assign
+ * @param $variableName Name of the variable we want to assign
+ * @return void
+ */
+ public function assignTemplateWithVariable (string $templateName, string $variableName) {
+ // Call the inner class' method
+ $this->getTemplateInstance()->assignTemplateWithVariable($templateName, $variableName);
+ }
+
+ /**
+ * Transfers the content of this template engine to a given response instance
+ *
+ * @param $responseInstance An instance of a Responseable class
+ * @return void
+ */
+ public function transferToResponse (Responseable $responseInstance) {
+ // Call the inner class' method
+ $this->getTemplateInstance()->transportToResponse($responseInstance);
+ }
+
+ /**
+ * Assigns all the application data with template variables
+ *
+ * @return void
+ */
+ public function assignApplicationData () {
+ // Call the inner class' method
+ $this->getTemplateInstance()->assignApplicationData();
+ }
+
+ /**
+ * "Compiles" a variable by replacing {?var?} with it's content
+ *
+ * @param $rawCode Raw code to compile
+ * @param $setMatchAsCode Sets $match if readVariable() returns empty result
+ * @return $rawCode Compile code with inserted variable value
+ */
+ public function compileRawCode (string $rawCode, bool $setMatchAsCode = false) {
+ return $this->getTemplateInstance()->compileRawCode($rawCode, $setMatchAsCode);
+ }
+
+ /**
+ * Getter for variable group array
+ *
+ * @return $variableGroups All variable groups
+ */
+ public final function getVariableGroups () {
+ // Call the inner class' method
+ return $this->getTemplateInstance()->getVariableGroups();
+ }
+
+ /**
+ * Getter for raw template data
+ *
+ * @return $rawTemplateData The raw data from the template
+ */
+ public function getRawTemplateData () {
+ // Call the inner class' method
+ return $this->getTemplateInstance()->getRawTemplateData();
+ }
+
+ /**
+ * Renames a variable in code and in stack
+ *
+ * @param $oldName Old name of variable
+ * @param $newName New name of variable
+ * @return void
+ */
+ public function renameVariable (string $oldName, string $newName) {
+ // Call the inner class' method
+ $this->getTemplateInstance()->renameVariable($oldName, $newName);
+ }
+
+ /**
+ * Renders the given XML content
+ *
+ * @param $content Valid XML content or if not set the current loaded raw content
+ * @return void
+ * @throws XmlParserException If an XML error was found
+ */
+ public function renderXmlContent (string $content = NULL) {
+ // Call the inner class' method
+ $this->getTemplateInstance()->renderXmlContent($content);
+ }
+
+ /**
+ * Enables or disables language support
+ *
+ * @param $languageSupport New language support setting
+ * @return void
+ */
+ public function enableLanguageSupport (bool $languageSupport = true) {
+ // Call the inner class' method
+ $this->getTemplateInstance()->enableLanguageSupport($languageSupport);
+ }
+
+ /**
+ * Checks whether language support is enabled
+ *
+ * @return $languageSupport Whether language support is enabled or disabled
+ */
+ public function isLanguageSupportEnabled () {
+ // Call the inner class' method
+ return $this->getTemplateInstance()->isLanguageSupportEnabled();
+ }
+
+ /**
+ * Enables or disables XML compacting
+ *
+ * @param $xmlCompacting New XML compacting setting
+ * @return void
+ */
+ public function enableXmlCompacting (bool $xmlCompacting = true) {
+ // Call the inner class' method
+ $this->getTemplateInstance()->enableXmlCompacting($xmlCompacting);
+ }
+
+ /**
+ * Checks whether XML compacting is enabled
+ *
+ * @return $xmlCompacting Whether XML compacting is enabled or disabled
+ */
+ public function isXmlCompactingEnabled () {
+ // Call the inner class' method
+ return $this->getTemplateInstance()->isXmlCompactingEnabled();
+ }
+
+ /**
+ * Handles the start element of an XML resource
+ *
+ * @param $resource XML parser resource (currently ignored)
+ * @param $element The element we shall handle
+ * @param $attributes All attributes
+ * @return void
+ * @throws InvalidXmlNodeException If an unknown/invalid XML node name was found
+ */
+ public function startElement ($resource, string $element, array $attributes) {
+ // Call the inner class' method
+ $this->getTemplateInstance()->startElement($resource, $element, $attributes);
+ }
+
+ /**
+ * Ends the main or sub node by sending out the gathered data
+ *
+ * @param $resource An XML resource pointer (currently ignored)
+ * @param $nodeName Name of the node we want to finish
+ * @return void
+ * @throws XmlNodeMismatchException If current main node mismatches the closing one
+ */
+ public function finishElement ($resource, string $nodeName) {
+ // Call the inner class' method
+ $this->getTemplateInstance()->finishElement($resource, $nodeName);
+ }
+
+ /**
+ * Currently not used
+ *
+ * @param $resource XML parser resource (currently ignored)
+ * @param $characters Characters to handle
+ * @return void
+ * @todo Find something useful with this!
+ */
+ public function characterHandler ($resource, string $characters) {
+ // Call the inner class' method but trim the characters before
+ $this->getTemplateInstance()->characterHandler($resource, trim($characters));
+ }
+
+ /**
+ * Removes all comments, tabs and new-line charcters to compact the content
+ *
+ * @param $uncompactedContent The uncompacted content
+ * @return $compactedContent The compacted content
+ */
+ public function compactContent (string $uncompactedContent) {
+ // Compact it ...
+ $compactedContent = $this->getTemplateInstance()->compactContent($uncompactedContent);
+
+ // ... and return it
+ return $compactedContent;
+ }
+
+ /**
+ * Assigns a lot variables into the stack of currently loaded template.
+ * This method should only be used in very rare circumstances, e.g. when
+ * you have to copy a whole set of variables into the template engine.
+ * Before you use this method, please make sure you have considered all
+ * other possiblities.
+ *
+ * @param $variables An array with variables to be assigned
+ * @return void
+ */
+ public function assignMultipleVariables (array $variables) {
+ // Call the inner class' method but trim the characters before
+ $this->getTemplateInstance()->assignMultipleVariables($variables);
+ }
+
+}
/**
* Protected constructor
*
- * @param $fullClassName Name of the real class (not BaseFactory)
+ * @param $className Name of the real class (not BaseFactory)
* @return void
*/
- protected function __construct ($fullClassName) {
+ protected function __construct (string $className) {
// Call parent constructor
- parent::__construct($fullClassName);
+ parent::__construct($className);
}
/**
*
* @param $fullClassName Name of the class we shall count
*/
- protected static final function countObject ($fullClassName) {
+ protected static final function countObject (string $fullClassName) {
// Count it up in total sum
self::$total++;
// Do we have an entry?
- if (!isset(self::$objectCounters[$fullClassName])) {
+ if (!self::isClassCounted($fullClassName)) {
// No, then generate one
self::$objectCounters[$fullClassName] = 0;
- } // END - if
+ }
// Count it up again
//* NOISY-DEBUG: */ print __METHOD__.': className=' .$fullClassName . PHP_EOL;
return self::$objectCounters;
}
+ /**
+ * Checks whether given full class name is already counted
+ *
+ * @param $fullClassName Full name of class
+ * @return $isCounted Whether given class name is counted
+ */
+ protected static final function isClassCounted (string $fullClassName) {
+ // Return isset() result
+ return isset(self::$objectCounters[$fullClassName]);
+ }
+
}
*
* @return $frontendInstance A database frontend instance
*/
- public static final function createFrontendByConfiguredName ($frontendName) {
+ public static final function createFrontendByConfiguredName (string $frontendName) {
// Get registry instance
$registryInstance = GenericRegistry::getRegistry();
if (!empty($action)) {
// Then use both for config entry
$configEntry = sprintf('news_reader_%s_%s_class', $command, $action);
- } // END - if
- } // END - if
+ }
+ }
// Get the news reader class name from config
$className = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry($configEntry);
use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
// Import SPL stuff
+use \InvalidArgumentException;
use \SplFileInfo;
/**
*
* @param $infoInstance An instance of a SplFileInfo class
* @return $indexInstance An instance of a IndexableStack class
+ * @throws InvalidArgumentException If a parameter is invalid
*/
public static final function createFileStackIndexInstance (SplFileInfo $infoInstance, string $type) {
// If there is no handler?
- if (GenericRegistry::getRegistry()->instanceExists($type . '_index')) {
+ if (empty($type)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "type" is empty');
+ } elseif (GenericRegistry::getRegistry()->instanceExists($type . '_index')) {
// Get handler from registry
$indexInstance = GenericRegistry::getRegistry()->getInstance($type . '_index');
} else {
/**
* Protected constructor
*
- * @param $fullClassName Name of this class
+ * @param $className Name of this class
* @return void
*/
- protected function __construct ($fullClassName = __CLASS__) {
+ protected function __construct (string $className = __CLASS__) {
// Call parent constructor
- parent::__construct($fullClassName);
+ parent::__construct($className);
}
/**
* the class was not found. No parameters for the object are currently
* supported.
*
- * @param $fullClassName Name of the class we shall construct
+ * @param $fullClassName Name of the class we shall construct
* @param $args Arguments in an indexed array
* @return $objectInstance An instance of the requested object
* @throws NoClassException If the requested class was not found
* @throws InvalidArgumentException If className is empty or the name not following naming-convention
*/
- public static final function createObjectByName ($fullClassName, array $args = []) {
+ public static final function createObjectByName (string $fullClassName, array $args = []) {
// Is the class name valid and is the class there?
if (empty($fullClassName)) {
// Throw an exception here
- throw new InvalidArgumentException('Parameter "className" is empty');
- } elseif (!class_exists($fullClassName)) {
+ throw new InvalidArgumentException('Parameter "fullClassName" is empty');
+ } elseif (!self::isClassCounted($fullClassName) && !class_exists($fullClassName)) {
// First get an instance of this factory
$factoryInstance = new ObjectFactory();
if (count($classNameParts) < 4) {
// Namespaces are missing
throw new InvalidArgumentException(sprintf('Class name "%s" is not conform to naming-convention: Tld\Domain\Project\Package[\SubPackage...]\SomeFooBar', $fullClassName));
- } // END - if
+ }
// Create method name
$methodName = sprintf('create%s', self::stripNamespaceFromClassName($fullClassName));
// Run the user function
- $objectInstance = call_user_func_array(array($fullClassName, $methodName), $args);
+ $objectInstance = call_user_func_array([$fullClassName, $methodName], $args);
// Count this one up
self::countObject($fullClassName);
/**
* Creates an object by it's configured name
*
- * @param $configEnttry Configuration entry to read
+ * @param $configKey Configuration key to read
* @param $args Arguments in an indexed array
* @return $objectInstance An instance of the requested object
*/
- public static final function createObjectByConfiguredName ($configEntry, array $args = []) {
+ public static final function createObjectByConfiguredName (string $configKey, array $args = []) {
// Read the configuration entry
- $fullClassName = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry($configEntry);
+ $fullClassName = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry($configKey);
// Send this to the other factory...
$objectInstance = self::createObjectByName($fullClassName, $args);
* @param $fullClassName Class name with namespace
* @return $shortClassName Stripped class name (no namespace)
*/
- private static function stripNamespaceFromClassName ($fullClassName) {
+ private static function stripNamespaceFromClassName (string $fullClassName) {
// The class name should contain at least 2 back-slashes, so split at them
$classNameParts = explode("\\", $fullClassName);
* the registry it will be returned, else a new instance is created and
* stored in the same registry entry.
*
- * @param $configEntry Config entry name for the template engine
+ * @param $configKey Config entry name for the template engine
* @return $templateInstance A template engine instance
*/
- public static final function createXmlTemplateEngineInstance (string $configEntry) {
+ public static final function createXmlTemplateEngineInstance (string $configKey) {
// Do we have an instance in the registry?
- if (GenericRegistry::getRegistry()->instanceExists($configEntry)) {
+ if (GenericRegistry::getRegistry()->instanceExists($configKey)) {
// Then use this instance
- $templateInstance = GenericRegistry::getRegistry()->getInstance($configEntry);
+ $templateInstance = GenericRegistry::getRegistry()->getInstance($configKey);
} else {
- // Now prepare the tags instance
- $templateInstance = ObjectFactory::createObjectByConfiguredName($configEntry);
+ // Get the XML template instance
+ $templateInstance = ObjectFactory::createObjectByConfiguredName($configKey);
// Disable language support
$templateInstance->enableLanguageSupport(false);
$templateInstance->enableXmlCompacting();
// Set the instance in registry for further use
- GenericRegistry::getRegistry()->addInstance($configEntry, $templateInstance);
+ GenericRegistry::getRegistry()->addInstance($configKey, $templateInstance);
}
// Return the instance
+++ /dev/null
-<?php
-// Own namespace
-namespace Org\Mxchange\CoreFramework\Deprecated;
-
-// Import framework stuff
-use Org\Mxchange\CoreFramework\Generic\FrameworkException;
-use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
-
-/**
- * An exception thrown when an instance variable instances a non-object
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.org
- * @deprecated Don't use this anymore
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class InvalidObjectException extends FrameworkException {
- /**
- * The constructor
- *
- * @param $class Class throwing the exception
- * @param $code Code number for the exception
- * @return void
- */
- public function __construct (FrameworkInterface $class, int $code) {
- // Add a message around the missing class
- $message = sprintf('[%s:%d] Object is not allowed here.',
- $class->__toString(),
- $this->getLine()
- );
-
- // Call parent constructor
- parent::__construct($message, $code);
- }
-
-}
*
* @param $streamData Mixed non-object stream data
* @return $streamData The compressed stream data
- * @throws InvalidObjectException If the stream is an object
+ * @throws InvalidArgumentException If the stream is not compressable or decompressable
*/
function compressStream ($streamData);
*
* @param $streamData Mixed non-object stream data
* @return $streamData The decompressed stream data
- * @throws InvalidObjectException If the stream is an object
+ * @throws InvalidArgumentException If the stream is not compressable or decompressable
*/
function decompressStream ($streamData);