+++ /dev/null
-Deny from all
use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
use Org\Mxchange\CoreFramework\Loader\ClassLoader;
use Org\Mxchange\CoreFramework\Manager\ManageableApplication;
+use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
use Org\Mxchange\CoreFramework\Registry\Registerable;
use Org\Mxchange\CoreFramework\Template\CompileableTemplate;
use Org\Mxchange\CoreFramework\Utils\Strings\StringUtils;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
*
* This program is free software: you can redistribute it and/or modify
* @return void
*/
public function initApplication () {
- // Get config instance
- $cfg = FrameworkBootstrap::getConfigurationInstance();
-
// Initialize output system
self::createDebugInstance('ApplicationHelper');
* method.
*/
FrameworkBootstrap::initDatabaseInstance();
-
- // Register core tests
- ClassLoader::registerTestsPath('framework/main/tests');
-
- // Register own tests
- ClassLoader::registerTestsPath('application/tests/tests');
-
- // Scan for them now
- ClassLoader::scanTestsClasses();
}
/**
$this->getControllerInstance()->handleRequest($requestInstance, $responseInstance);
// -------------------------- Shutdown phase --------------------------
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MAIN: Shutdown in progress ...');
+ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('MAIN: Shutdown in progress ...');
$this->getControllerInstance()->executeShutdownFilters($requestInstance, $responseInstance);
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MAIN: Shutdown completed. (This is the last line.)');
+ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('MAIN: Shutdown completed. (This is the last line.)');
}
/**
* @todo Nothing to add?
*/
public function assignExtraTemplateData (CompileableTemplate $templateInstance) {
- $this->partialStub('Unfinished method. templateInstance=' . $templateInstance->__toString());
+ DebugMiddleware::getSelfInstance()->partialStub('Unfinished method. templateInstance=' . $templateInstance->__toString());
}
}
--- /dev/null
+<?php
+// Own namespace
+namespace Org\Mxchange\CoreFramework\Tests\Command;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Command\BaseCommand;
+use Org\Mxchange\CoreFramework\Command\Commandable;
+use Org\Mxchange\CoreFramework\Controller\Controller;
+use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
+use Org\Mxchange\CoreFramework\Registry\Object\ObjectRegistry;
+use Org\Mxchange\CoreFramework\Request\Requestable;
+use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver;
+use Org\Mxchange\CoreFramework\Response\Responseable;
+
+/**
+ * A command for the 'main' routine
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 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 TestsConsoleMainCommand extends BaseCommand implements Commandable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ private function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @param $resolverInstance An instance of a command resolver class
+ * @return $commandInstance An instance a prepared command class
+ */
+ public static final function createTestsConsoleMainCommand (CommandResolver $resolverInstance) {
+ // Get new instance
+ $commandInstance = new TestsConsoleMainCommand();
+
+ // Set the application instance
+ $commandInstance->setResolverInstance($resolverInstance);
+
+ // Return the prepared instance
+ return $commandInstance;
+ }
+
+ /**
+ * Executes the given command with given request and response objects
+ *
+ * @param $requestInstance An instance of a class with an Requestable interface
+ * @param $responseInstance An instance of a class with an Responseable interface
+ * @return void
+ */
+ public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ // Debug message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('TESTS-CONSOLE-MAIN-COMMAND: requestInstance=%s,responseInstance=%s - CALLED!', $requestInstance->__toString(), $responseInstance->__toString()));
+ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('MAIN: --- Starting tests ... ---');
+
+ // Get controller
+ $controllerInstance = ObjectRegistry::getRegistry('generic')->getInstance('controller');
+
+ // Run all tests
+ $controllerInstance->executeTestsFilters($requestInstance, $responseInstance);
+
+ // Debug message
+ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('MAIN: --- Leaving main ... ---');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('TESTS-CONSOLE-MAIN-COMMAND: EXIT!');
+ }
+
+ /**
+ * Adds extra filters to the given controller instance
+ *
+ * @param $controllerInstance A controller instance
+ * @param $requestInstance An instance of a class with an Requestable interface
+ * @return void
+ */
+ public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
+ // Add pre filters (e.g. for requirements checks)
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('TESTS-CONSOLE-MAIN-COMMAND: controllerInstance=%s,requestInstance=%s - CALLED!', $controllerInstance->__toString(), $requestInstance->__toString()));
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('tests_php_requirements_filter_class'));
+
+ // Add 'tests' filters which will run the actual tests
+ $controllerInstance->addTestsFilter(ObjectFactory::createObjectByConfiguredName('tests_configuration_classes_loadable_filter_class'));
+ $controllerInstance->addTestsFilter(ObjectFactory::createObjectByConfiguredName('tests_configuration_is_enabled_filter_class'));
+
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('TESTS-CONSOLE-MAIN-COMMAND: EXIT!');
+ }
+
+}
--- /dev/null
+<?php
+// Own namespace
+namespace Org\Mxchange\CoreFramework\Tests\Controller;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Controller\BaseController;
+use Org\Mxchange\CoreFramework\Controller\Controller;
+use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
+use Org\Mxchange\CoreFramework\Filter\Filterable;
+use Org\Mxchange\CoreFramework\Request\Requestable;
+use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver;
+use Org\Mxchange\CoreFramework\Response\Responseable;
+
+/**
+ * The default controller with news for e.g. home or news page
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 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 TestsConsoleDefaultNewsController extends BaseController implements Controller {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ private function __construct () {
+ // Call parent constructor
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('TEST-CONSOLE-DEFAULT-NEWS-CONTROLLER: CONSTRUCTED!');
+ parent::__construct(__CLASS__);
+
+ // Init additional filter chains
+ foreach (['bootstrap', 'tests', BaseController::FILTER_CHAIN_SHUTDOWN] as $filterChain) {
+ // Init filter chain
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('TEST-CONSOLE-DEFAULT-NEWS-CONTROLLER: Initializing filterChain=%s ...', $filterChain));
+ $this->initFilterChain($filterChain);
+ }
+
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('TEST-CONSOLE-DEFAULT-NEWS-CONTROLLER: EXIT!');
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @param $resolverInstance An instance of a command resolver class
+ * @return $controllerInstance A prepared instance of this class
+ */
+ public static final function createTestsConsoleDefaultNewsController (CommandResolver $resolverInstance) {
+ // Create the instance
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('TEST-CONSOLE-DEFAULT-NEWS-CONTROLLER: resolverInstance=%s - CALLED!', $resolverInstance->__toString()));
+ $controllerInstance = new TestsConsoleDefaultNewsController();
+
+ // Set the command resolver
+ $controllerInstance->setResolverInstance($resolverInstance);
+
+ // Add news filters to this controller
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_download_filter_class'));
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_process_filter_class'));
+
+ // Return the prepared instance
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('TEST-CONSOLE-DEFAULT-NEWS-CONTROLLER: controllerInstance=%s - EXIT!', $controllerInstance->__toString()));
+ return $controllerInstance;
+ }
+
+ /**
+ * Handles the given request and response
+ *
+ * @param $requestInstance An instance of a request class
+ * @param $responseInstance An instance of a response class
+ * @return void
+ */
+ public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) {
+ // Get the command instance from the resolver by sending a request instance to the resolver
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('TEST-CONSOLE-DEFAULT-NEWS-CONTROLLER: requestInstance=%s,responseInstance=%s - CALLED!', $requestInstance->__toString(), $responseInstance->__toString()));
+ $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance);
+
+ // Add more filters by the command
+ $commandInstance->addExtraFilters($this, $requestInstance);
+
+ // Run the pre filters
+ $this->executePreFilters($requestInstance, $responseInstance);
+
+ // This request was valid! :-D
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('TEST-CONSOLE-DEFAULT-NEWS-CONTROLLER: Invoking requestInstance->setIsRequestValid(TRUE) ...');
+ $requestInstance->setIsRequestValid(TRUE);
+
+ // Execute the command
+ $commandInstance->execute($requestInstance, $responseInstance);
+
+ // Run the post filters
+ $this->executePostFilters($requestInstance, $responseInstance);
+
+ // Flush the response out
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('TEST-CONSOLE-DEFAULT-NEWS-CONTROLLER: Invoking responseInstance->flushBuffer() ...');
+ $responseInstance->flushBuffer();
+
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('TEST-CONSOLE-DEFAULT-NEWS-CONTROLLER: EXIT!');
+ }
+
+ /**
+ * Add a bootstrap filter
+ *
+ * @param $filterInstance A Filterable class
+ * @return void
+ */
+ public function addBootstrapFilter (Filterable $filterInstance) {
+ $this->addFilter('bootstrap', $filterInstance);
+ }
+
+ /**
+ * Add a tests filter
+ *
+ * @param $filterInstance A Filterable class
+ * @return void
+ */
+ public function addTestsFilter (Filterable $filterInstance) {
+ $this->addFilter('tests', $filterInstance);
+ }
+
+ /**
+ * Executes all bootstrap filters
+ *
+ * @param $requestInstance A Requestable class
+ * @param $responseInstance A Responseable class
+ * @return void
+ */
+ public function executeBootstrapFilters (Requestable $requestInstance, Responseable $responseInstance) {
+ $this->executeFilters('bootstrap', $requestInstance, $responseInstance);
+ }
+
+ /**
+ * Executes all tests filters
+ *
+ * @param $requestInstance A Requestable class
+ * @param $responseInstance A Responseable class
+ * @return void
+ */
+ public function executeTestsFilters (Requestable $requestInstance, Responseable $responseInstance) {
+ $this->executeFilters('tests', $requestInstance, $responseInstance);
+ }
+
+}
--- /dev/null
+<?php
+// Own namespace
+namespace Org\Mxchange\CoreFramework\Tests\Filter;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Filter\BaseFilter;
+
+/**
+ * A generic filter for tests
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 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/>.
+ */
+abstract class BaseTestsFilter extends BaseFilter {
+ /**
+ * Protected constructor
+ *
+ * @param $className Real name of class
+ * @return void
+ */
+ protected function __construct (string $className) {
+ // Call parent constructor
+ parent::__construct($className);
+ }
+
+}
--- /dev/null
+<?php
+// Own namespace
+namespace Org\Mxchange\CoreFramework\Tests\Filter\???;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
+use Org\Mxchange\CoreFramework\Filter\Filterable;
+use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
+use Org\Mxchange\CoreFramework\Request\Requestable;
+use Org\Mxchange\CoreFramework\Response\Responseable;
+use Org\Mxchange\CoreFramework\Tests\Filter\BaseTestsFilter;
+
+// Import SPL stuff
+use \InvalidArgumentException;
+
+/**
+ * A ??? filter for tests
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.ship-simu.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 Tests???Filter extends BaseTestsFilter implements Filterable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ private function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this filter class
+ *
+ * @return $filterInstance An instance of this filter class
+ */
+ public final static function createTests???Filter () {
+ // Get a new instance
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('TESTS-|||-FILTER: CALLED!');
+ $filterInstance = new Tests???Filter();
+
+ // Return the instance
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('TESTS-|||-FILTER: filterInstance=%s - EXIT!', $filterInstance->__toString()));
+ return $filterInstance;
+ }
+
+ /**
+ * Executes the filter with given request and response objects
+ *
+ * @param $requestInstance An instance of a class with an Requestable interface
+ * @param $responseInstance An instance of a class with an Responseable interface
+ * @return void
+ * @todo 0% done
+ */
+ public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ // Init counter
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('TESTS-|||-FILTER: requestInstance=%s,responseInstance=%s - CALLED!', $requestInstance->__toString(), $responseInstance->__toString()));
+ $passed = $failed = $skipped = $warning = 0;
+
+ // Implement this!
+ DebugMiddleware::getSelfInstance()->partialStub('Please implement this method.');
+
+ // Calculate percentage
+ $percent = (($passed + $failed) > 0 ? ($passed / ($passed + $failed) * 100) : 0);
+
+ // Output result
+ self::createDebugInstance(__CLASS__, __LINE__)->infoMessage(sprintf('Test result: %d okay, %d failed (%0.02f%% passed), %d skipped, %d warnings', $passed, $failed, $percent, $skipped, $warning));
+
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('TESTS-|||-FILTER: EXIT!');
+ }
+
+}
--- /dev/null
+<?php
+// Own namespace
+namespace Org\Mxchange\CoreFramework\Tests\Filter\Configuration\???;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
+use Org\Mxchange\CoreFramework\Filter\Filterable;
+use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
+use Org\Mxchange\CoreFramework\Request\Requestable;
+use Org\Mxchange\CoreFramework\Response\Responseable;
+use Org\Mxchange\CoreFramework\Tests\Filter\BaseTestsFilter;
+
+// Import SPL stuff
+use \InvalidArgumentException;
+
+/**
+ * A ??? filter for configuration tests
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.ship-simu.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 TestsConfiguration???Filter extends BaseTestsFilter implements Filterable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ private function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this filter class
+ *
+ * @return $filterInstance An instance of this filter class
+ */
+ public final static function createTestsConfiguration???Filter () {
+ // Get a new instance
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('TESTS-CONFIGURATION-|||-FILTER: CALLED!');
+ $filterInstance = new TestsConfiguration???Filter();
+
+ // Return the instance
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('TESTS-CONFIGURATION-|||-FILTER: filterInstance=%s - EXIT!', $filterInstance->__toString()));
+ return $filterInstance;
+ }
+
+ /**
+ * Executes the filter with given request and response objects
+ *
+ * @param $requestInstance An instance of a class with an Requestable interface
+ * @param $responseInstance An instance of a class with an Responseable interface
+ * @return void
+ * @todo 0% done
+ */
+ public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ // Init counter
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('TESTS-CONFIGURATION-|||-FILTER: requestInstance=%s,responseInstance=%s - CALLED!', $requestInstance->__toString(), $responseInstance->__toString()));
+ $passed = $failed = $skipped = $warning = 0;
+
+ // Implement this!
+ DebugMiddleware::getSelfInstance()->partialStub('Please implement this method.');
+
+ // Calculate percentage
+ $percent = (($passed + $failed) > 0 ? ($passed / ($passed + $failed) * 100) : 0);
+
+ // Output result
+ self::createDebugInstance(__CLASS__, __LINE__)->infoMessage(sprintf('Test result: %d okay, %d failed (%0.02f%% passed), %d skipped, %d warning - EXIT!', $passed, $failed, $percent, $skipped, $warning));
+
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('TESTS-CONFIGURATION-|||-FILTER: EXIT!');
+ }
+
+}
--- /dev/null
+<?php
+// Own namespace
+namespace Org\Mxchange\CoreFramework\Tests\Filter\Configuration\Classes;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
+use Org\Mxchange\CoreFramework\Filter\Filterable;
+use Org\Mxchange\CoreFramework\Request\Requestable;
+use Org\Mxchange\CoreFramework\Response\Responseable;
+use Org\Mxchange\CoreFramework\Tests\Filter\BaseTestsFilter;
+
+// Import SPL stuff
+use \InvalidArgumentException;
+
+/**
+ * A LoadableClasses filter for tests
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.ship-simu.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 TestConfigurationLoadableClassesFilter extends BaseTestsFilter implements Filterable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ private function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this filter class
+ *
+ * @return $filterInstance An instance of this filter class
+ */
+ public final static function createTestConfigurationLoadableClassesFilter () {
+ // Get a new instance
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('TESTS-CONFIGURATION-LOADABLE-CLASSES-FILTER: CALLED!');
+ $filterInstance = new TestConfigurationLoadableClassesFilter();
+
+ // Return the instance
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('TESTS-CONFIGURATION-LOADABLE-CLASSES-FILTER: filterInstance=%s - EXIT!', $filterInstance->__toString()));
+ return $filterInstance;
+ }
+
+ /**
+ * Executes the filter with given request and response objects
+ *
+ * @param $requestInstance An instance of a class with an Requestable interface
+ * @param $responseInstance An instance of a class with an Responseable interface
+ * @return void
+ */
+ public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ // Init counter
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('TESTS-CONFIGURATION-LOADABLE-CLASSES-FILTER: requestInstance=%s,responseInstance=%s - CALLED!', $requestInstance->__toString(), $responseInstance->__toString()));
+ $passed = $failed = $skipped = $warning = 0;
+
+ // Loop through all configuration keys
+ foreach (FrameworkBootstrap::getConfigurationInstance()->getConfigurationArray() as $configKey => $configValue) {
+ // Key must end with _class
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('TESTS-CONFIGURATION-LOADABLE-CLASSES-FILTER: configKey[%s]=%s,configValue[%s]=%s', gettype($configKey), $configKey, gettype($configValue), $configValue));
+ if (substr($configKey, -6, 6) != '_class') {
+ // Skip this
+ $skipped++;
+ continue;
+ }
+
+ // This may throw exceptions
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('Testing configKey[%s]=%s,configValue[%s]=%s', gettype($configKey), $configKey, gettype($configValue), $configValue));
+ try {
+ // Is the config entry valid and class is there?
+ if (!is_string($configValue)) {
+ // Skip further tests
+ self::createDebugInstance(__CLASS__, __LINE__)->warningMessage(sprintf('configValue=%s has unexpected type "%s", required: string - FAILED!', $configValue, gettype($configValue)));
+ $failed++;
+ continue;
+ } elseif (!class_exists($configValue)) {
+ // Skip further tests
+ self::createDebugInstance(__CLASS__, __LINE__)->warningMessage(sprintf('Class "%s" not found. FAILED!', $configValue));
+ $failed++;
+ continue;
+ }
+ } catch (InvalidArgumentException $e) {
+ // Maybe not conform?
+ self::createDebugInstance(__CLASS__, __LINE__)->warningMessage(sprintf('Class "%s" failed to load. Message: "%s"', $configValue, $e->getMessage()));
+
+ // Skip further tests
+ $failed++;
+ continue;
+ }
+
+ // class_exists() didn't fail
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('Class "%s" loaded successfully. OKAY', $configValue));
+ $passed++;
+ }
+
+ // Calculate percentage
+ $percent = (($passed + $failed) > 0 ? ($passed / ($passed + $failed) * 100) : 0);
+
+ // Output result
+ self::createDebugInstance(__CLASS__, __LINE__)->infoMessage(sprintf('Test result: %d okay, %d failed (%0.02f%% passed), %d skipped, %d warning - EXIT!', $passed, $failed, $percent, $skipped, $warning));
+
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('TESTS-CONFIGURATION-LOADABLE-CLASSES-FILTER: EXIT!');
+ }
+
+}
--- /dev/null
+<?php
+// Own namespace
+namespace Org\Mxchange\CoreFramework\Tests\Filter\Configuration\IsEnabled;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
+use Org\Mxchange\CoreFramework\Filter\Filterable;
+use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
+use Org\Mxchange\CoreFramework\Request\Requestable;
+use Org\Mxchange\CoreFramework\Response\Responseable;
+use Org\Mxchange\CoreFramework\Tests\Filter\BaseTestsFilter;
+
+// Import SPL stuff
+use \InvalidArgumentException;
+
+/**
+ * A IsEnabled filter for configuration tests
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.ship-simu.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 TestsConfigurationIsEnabledFilter extends BaseTestsFilter implements Filterable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ private function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this filter class
+ *
+ * @return $filterInstance An instance of this filter class
+ */
+ public final static function createTestsConfigurationIsEnabledFilter () {
+ // Get a new instance
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('TESTS-CONFIGURATION-IS-ENABLED-FILTER: CALLED!');
+ $filterInstance = new TestsConfigurationIsEnabledFilter();
+
+ // Return the instance
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('TESTS-CONFIGURATION-IS-ENABLED-FILTER: filterInstance=%s - EXIT!', $filterInstance->__toString()));
+ return $filterInstance;
+ }
+
+ /**
+ * Executes the filter with given request and response objects
+ *
+ * @param $requestInstance An instance of a class with an Requestable interface
+ * @param $responseInstance An instance of a class with an Responseable interface
+ * @return void
+ * @todo 0% done
+ */
+ public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ // Init counter
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('TESTS-CONFIGURATION-IS-ENABLED-FILTER: requestInstance=%s,responseInstance=%s - CALLED!', $requestInstance->__toString(), $responseInstance->__toString()));
+ $passed = $failed = $skipped = $warning = 0;
+
+ // Loop through all configuration keys
+ foreach (FrameworkBootstrap::getConfigurationInstance()->getConfigurationArray() as $configKey => $configValue) {
+ // Key must end with _class
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('TESTS-CONFIGURATION-IS-ENABLED-FILTER: configKey[%s]=%s,configValue[%s]=%s', gettype($configKey), $configKey, gettype($configValue), $configValue));
+ if (substr($configKey, 0, 3) != 'is_' && substr($configKey, -8, 8) != '_enabled') {
+ // Is this a boolean value?
+ if (is_bool($configValue)) {
+ // Issue a warning
+ self::createDebugInstance(__CLASS__, __LINE__)->warningMessage(sprintf('TESTS-CONFIGURATION-IS-ENABLED-FILTER: comnfigKey=%s has a boolean value[]=%s', $configKey, gettype($configValue)));
+ $warning++;
+ } else {
+ // Mark as skipped
+ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('TESTS-CONFIGURATION-IS-ENABLED-FILTER: comnfigKey=%s is not wanted here - SKIPPED!', $configKey));
+ $skipped++;
+ }
+
+ // Skip this
+ continue;
+ }
+
+ // Is it boolean?
+ if (!is_bool($configValue)) {
+ // Failed!
+ self::createDebugInstance(__CLASS__, __LINE__)->warningMessage(sprintf('Configuration key "%s" is NOT boolean. FAILED', $configKey));
+ $failed++;
+ } else {
+ // Count as success
+ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('Configuration key "%s" is a boolean feature. OKAY', $configKey));
+ $passed++;
+ }
+ }
+
+ // Calculate percentage
+ $percent = (($passed + $failed) > 0 ? ($passed / ($passed + $failed) * 100) : 0);
+
+ // Output result
+ self::createDebugInstance(__CLASS__, __LINE__)->infoMessage(sprintf('Test result: %d okay, %d failed (%0.02f%% passed), %d skipped, $d warnings', $passed, $failed, $percent, $skipped, $warning));
+
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('TESTS-CONFIGURATION-IS-ENABLED-FILTER: EXIT!');
+ }
+
+}
--- /dev/null
+<?php
+// Own namespace
+namespace Org\Mxchange\CoreFramework\Tests\Filter\PhpRequirements;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
+use Org\Mxchange\CoreFramework\Filter\Filterable;
+use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
+use Org\Mxchange\CoreFramework\Request\Requestable;
+use Org\Mxchange\CoreFramework\Response\Responseable;
+use Org\Mxchange\CoreFramework\Tests\Filter\BaseTestsFilter;
+
+// Import SPL stuff
+use \InvalidArgumentException;
+
+/**
+ * A PhpRequirements filter for tests
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.ship-simu.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 TestsPhpRequirementsFilter extends BaseTestsFilter implements Filterable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ private function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this filter class
+ *
+ * @return $filterInstance An instance of this filter class
+ */
+ public final static function createTestsPhpRequirementsFilter () {
+ // Get a new instance
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('TESTS-PHP-REQUIREMENTS-FILTER: CALLED!');
+ $filterInstance = new TestsPhpRequirementsFilter();
+
+ // Return the instance
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('TESTS-PHP-REQUIREMENTS-FILTER: filterInstance=%s - EXIT!', $filterInstance->__toString()));
+ return $filterInstance;
+ }
+
+ /**
+ * Executes the filter with given request and response objects
+ *
+ * @param $requestInstance An instance of a class with an Requestable interface
+ * @param $responseInstance An instance of a class with an Responseable interface
+ * @return void
+ * @todo 0% done
+ */
+ public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ // Init counter
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('TESTS-PHP-REQUIREMENTS-FILTER: requestInstance=%s,responseInstance=%s - CALLED!', $requestInstance->__toString(), $responseInstance->__toString()));
+ $passed = $failed = $skipped = $warning = 0;
+
+ // Implement this!
+ DebugMiddleware::getSelfInstance()->partialStub('Please implement this method.');
+
+ // Calculate percentage
+ $percent = (($passed + $failed) > 0 ? ($passed / ($passed + $failed) * 100) : 0);
+
+ // Output result
+ self::createDebugInstance(__CLASS__, __LINE__)->infoMessage(sprintf('Test result: %d okay, %d failed (%0.02f%% passed), %d skipped, %d warnings', $passed, $failed, $percent, $skipped, $warning));
+
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('TESTS-PHP-REQUIREMENTS-FILTER: EXIT!');
+ }
+
+}
--- /dev/null
+<?php
+// Own namespace
+namespace Org\Mxchange\CoreFramework\Tests\Resolver\Command;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Command\InvalidCommandException;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
+use Org\Mxchange\CoreFramework\Resolver\Command\BaseCommandResolver;
+use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver;
+
+// Import SPL stuff
+use \InvalidArgumentException;
+
+/**
+ * A command resolver for console commands
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 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 TestsConsoleCommandResolver extends BaseCommandResolver implements CommandResolver {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ private function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set prefix to "TestsConsole"
+ $this->setClassPrefix('tests_console');
+ }
+
+ /**
+ * Creates an instance of a TestsConsole command resolver with a given default command
+ *
+ * @param $commandName The default command we shall execute
+ * @return $resolverInstance The prepared command resolver instance
+ * @throws InvalidArgumentException Thrown if default command is not set
+ * @throws InvalidCommandException Thrown if default command is invalid
+ */
+ public static final function createTestsConsoleCommandResolver (string $commandName) {
+ // Create the new instance
+ $resolverInstance = new TestsConsoleCommandResolver();
+
+ // Is the variable $commandName set and the command is valid?
+ if (empty($commandName)) {
+ // Then thrown an exception here
+ throw new InvalidArgumentException('Parameter "commandName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif ($resolverInstance->isCommandValid('Org\Mxchange\CoreFramework\Tests\Command', $commandName) === false) {
+ // Invalid command found
+ throw new InvalidCommandException(array($resolverInstance, $commandName), self::EXCEPTION_INVALID_COMMAND);
+ }
+
+ // Set namespace for command
+ $resolverInstance->setNamespace('Org\Mxchange\CoreFramework\Tests\Command');
+ $resolverInstance->setCommandName($commandName);
+
+ // Return the prepared instance
+ return $resolverInstance;
+ }
+
+}
--- /dev/null
+<?php
+// Own namespace
+namespace Org\Mxchange\CoreFramework\Tests\Resolver\Controller;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Controller\BaseController;
+use Org\Mxchange\CoreFramework\Controller\Controller;
+use Org\Mxchange\CoreFramework\Controller\InvalidControllerException;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
+use Org\Mxchange\CoreFramework\Resolver\Controller\BaseControllerResolver;
+use Org\Mxchange\CoreFramework\Resolver\Controller\ControllerResolver;
+
+// Import SPL stuff
+use \InvalidArgumentException;
+
+/**
+ * A resolver for resolving controllers locally
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 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 TestsConsoleControllerResolver extends BaseControllerResolver implements ControllerResolver {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ private function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set prefix to "TestsConsole"
+ $this->setClassPrefix('tests_console');
+ }
+
+ /**
+ * Creates an instance of a resolver class with a given command
+ *
+ * @param $controllerName The controller we shall resolve
+ * @return $resolverInstance The prepared controller resolver instance
+ * @throws InvalidArgumentException Thrown if default command is not set
+ * @throws InvalidControllerException Thrown if default controller is invalid
+ */
+ public static final function createTestsConsoleControllerResolver (string $controllerName) {
+ // Create the new instance
+ $resolverInstance = new TestsConsoleControllerResolver();
+
+ // Is the variable $controllerName set and the command is valid?
+ if (empty($controllerName)) {
+ // Then thrown an exception here
+ throw new InvalidArgumentException('Parameter "controllerName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif ($resolverInstance->isControllerValid('Org\Mxchange\CoreFramework\Tests\Controller', $controllerName) === false) {
+ // Invalid command found
+ throw new InvalidControllerException(array($resolverInstance, $controllerName), self::EXCEPTION_INVALID_CONTROLLER);
+ }
+
+ // Set namespace and controller name
+ $resolverInstance->setNamespace('Org\Mxchange\CoreFramework\Tests\Controller');
+ $resolverInstance->setControllerName($controllerName);
+
+ // Return the prepared instance
+ return $resolverInstance;
+ }
+
+}
--- /dev/null
+<?php
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
+
+/**
+ * Local configuration entries which you can customize. Please keep the
+ * comments starting with CFG: as-is or else, the later configuration wizard
+ * (aka. 'admin' project) will not be able to parse it. You need to rename this
+ * file to config-local.php and make in that new file your changes.
+ *
+ * If you want to start an own network (which may accept different types of
+ * objects which would be rejected by the global network) please change
+ * hub_bootstrap_nodes (semicolon-seperated list) to your bootstrapper.
+ *
+ * You can set external_address to a hostname, e.g. me.homelinux.org, which will be
+ * included in the announcement. This is very useful for consumer DSL
+ * connections because they might be disconnected every 24 hours and rotate the
+ * IP number.
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ *
+ * 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/>.
+ */
+
+// Some hub-specific configuration like port hostname where we will listen, etc.
+$cfg = FrameworkBootstrap::getConfigurationInstance();
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
*
* This program is free software: you can redistribute it and/or modify
$cfg->setConfigEntry('news_main_limit', 5);
// CFG: TESTS-PHP-REQUIREMENTS-FILTER
-$cfg->setConfigEntry('tests_php_requirements_filter_class', 'Org\Mxchange\CoreFramework\Tests\Filter\Requirements\TestsPhpRequirementsFilter');
+$cfg->setConfigEntry('tests_php_requirements_filter_class', 'Org\Mxchange\CoreFramework\Tests\Filter\PhpRequirements\TestsPhpRequirementsFilter');
// CFG: TEST-CONFIGURATION-CLASSES-LOADABLE-TEST-FILTER-CLASS
-$cfg->setConfigEntry('tests_configuration_classes_loadable_test_filter_class', 'Org\Mxchange\CoreFramework\Tests\Filter\Configuration\Classes\TestConfigurationLoadableClassesFilter');
+$cfg->setConfigEntry('tests_configuration_classes_loadable_filter_class', 'Org\Mxchange\CoreFramework\Tests\Filter\Configuration\Classes\TestConfigurationLoadableClassesFilter');
+
+// CFG: TEST-CONFIGURATION-IS-ENABLED-TEST-FILTER-CLASS
+$cfg->setConfigEntry('tests_configuration_is_enabled_filter_class', 'Org\Mxchange\CoreFramework\Tests\Filter\Configuration\IsEnabled\TestsConfigurationIsEnabledFilter');
// CFG: TEST-CONSOLE-CONTROLLER-RESOLVER-CLASS
$cfg->setConfigEntry('tests_console_controller_resolver_class', 'Org\Mxchange\CoreFramework\Tests\Resolver\Controller\TestsConsoleControllerResolver');
+++ /dev/null
-<?php
-/**
- * Application data
- *
- * Please remember that this include file is being loaded *before* the class
- * loader is loading classes from "exceptions", "interfaces" and "main"!
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 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/>.
- */
-
-// Get config instance
-$cfg = FrameworkConfiguration::getSelfInstance();
-
-// Get an instance of the helper
-$app = call_user_func_array(
- array($cfg->getConfigEntry('app_helper_class'), 'getSelfInstance'),
- []
-);
-
-// Set application name and version
-$app->setAppName('Unit tests and more');
-$app->setAppVersion('0.0.0');
-$app->setAppShortName('tests');
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
*
* This program is free software: you can redistribute it and/or modify
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
*
* This program is free software: you can redistribute it and/or modify
*/
// The node's own exception handler
-function tests_exception_handler ($exceptionInstance) {
+function core_exception_handler ($exceptionInstance) {
// Is it an object and a valid instance?
if ((is_object($exceptionInstance)) && ($exceptionInstance instanceof Exception)) {
// Init variable
$backTrace = '';
+ // Generate exception code
+ $exceptionCode = ($exceptionInstance instanceof FrameworkException ? $exceptionInstance->getHexCode() : '0x' . bin2hex($exceptionInstance->getCode()));
+
// Get all call levels from backtrace
foreach ($exceptionInstance->getTrace() as $idx => $traceArray) {
// Init argument string
$argsString = '';
- // Convert arguments type into human-readable
- foreach ($traceArray['args'] as $arg) {
- $argsString .= ', ' . gettype($arg);
+ // Arguments given?
+ if (isset($traceArray['args'])) {
+ // Convert arguments type into human-readable
+ foreach ($traceArray['args'] as $arg) {
+ $argsString .= ', ' . gettype($arg);
+ }
+ $argsString = substr($argsString, 2);
}
- $argsString = substr($argsString, 2);
// Set missing file/line
if (!isset($traceArray['file'])) $traceArray['file'] = 'unknown';
--------------------------------------------------------------------------------\n",
trim(html_entity_decode(strip_tags(get_class($exceptionInstance)))),
trim(html_entity_decode(strip_tags($exceptionInstance->getMessage()))),
- ($exceptionInstance instanceof FrameworkException ? $exceptionInstance->getHexCode() : '0x' . bin2hex($exceptionInstance->getCode())),
+ $exceptionCode,
$exceptionInstance->getFile(),
$exceptionInstance->getLine(),
trim($backTrace)
// Output the message
print($message);
+
+ // Exit with code
+ exit(hexdec($exceptionCode));
} elseif (is_object($exceptionInstance)) {
// Output more details
printf('exceptionInstance=%s', print_r($exceptionInstance, true));
+ exit(255);
} else {
/*
* Invalid exception instance detected! Do *only* throw exceptions that
* outputs like above.
*/
printf('exceptionInstance[]=%s is invalid! Please inform the core developer team.' . PHP_EOL, gettype($exceptionInstance));
+ exit(255);
}
}
// Error handler
-function tests_error_handler ($errno, $errstr, $errfile, $errline, array $errcontext) {
+function core_error_handler (int $errno, string $errstr, string $errfile, int $errline, array $errcontext) {
// Construct the message
- $message = sprintf('File: %s, Line: %s, Code: %s, Message: %s',
+ $message = sprintf('File: %s, Line: %d, Code: %d, Message: %s',
basename($errfile),
$errline,
$errno,
}
// Assertion handler
-function tests_assert_handler (string $file, int $line, $code) {
+function core_assert_handler (string $file, int $line, int $code) {
// Empty code?
- if ($code === '') {
+ if (empty($code)) {
$code = '<em>Unknown</em>';
}
}
// Set error handler
-//set_error_handler('tests_error_handler');
+//set_error_handler('core_error_handler');
// Set the new handler
-set_exception_handler('tests_exception_handler');
+set_exception_handler('core_exception_handler');
// Init assert handling
assert_options(ASSERT_ACTIVE , true);
-assert_options(ASSERT_WARNING , false);
+assert_options(ASSERT_WARNING , true);
assert_options(ASSERT_BAIL , true);
assert_options(ASSERT_QUIET_EVAL, false);
-assert_options(ASSERT_CALLBACK , 'tests_assert_handler');
+assert_options(ASSERT_CALLBACK , 'core_assert_handler');
+++ /dev/null
-<?php
-/**
- * The application's class loader
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
- * @license GNU GPL 3.0 or any newer version
- *
- * 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/>.
- */
-
-// Scan for application's classes, exceptions and interfaces
-ClassLoader::scanApplicationClasses();
+++ /dev/null
-<?php
-/**
- * The application launcher
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 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/>.
- */
-
-// Is there an application helper instance? We need the method main() for
-// maining the application
-$app = call_user_func_array(
- array(
- FrameworkConfiguration::getSelfInstance()->getConfigEntry('app_helper_class'), 'getSelfInstance'
- ), []
-);
-
-// Some sanity checks
-if ((empty($app)) || (is_null($app))) {
- // Something went wrong!
- ApplicationEntryPoint::app_exit(sprintf("[Main:] The application <span class=\"app_name\">%s</span> could not be launched because the helper class <span class=\"class_name\">%s</span> is not loaded.",
- $application,
- FrameworkConfiguration::getSelfInstance()->getConfigEntry('app_helper_class')
- ));
-} elseif (!is_object($app)) {
- // No object!
- ApplicationEntryPoint::app_exit(sprintf("[Main:] The application <span class=\"app_name\">%s</span> could not be launched because 'app' is not an object.",
- $application
- ));
-} elseif (!method_exists($app, FrameworkConfiguration::getSelfInstance()->getConfigEntry('entry_method'))) {
- // Method not found!
- ApplicationEntryPoint::app_exit(sprintf("[Main:] The application <span class=\"app_name\">%s</span> could not be launched because the method <span class=\"method_name\">%s</span> is missing.",
- $application,
- FrameworkConfiguration::getSelfInstance()->getConfigEntry('entry_method')
- ));
-}
-
-// Call user function
-call_user_func_array(array($app, FrameworkConfiguration::getSelfInstance()->getConfigEntry('entry_method')), []);
"content-hash": "ed9acb2394cfd19378859e9f830535f2",
"packages": [],
"packages-dev": [
+ {
+ "name": "doctrine/deprecations",
+ "version": "1.1.2",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/doctrine/deprecations.git",
+ "reference": "4f2d4f2836e7ec4e7a8625e75c6aa916004db931"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/doctrine/deprecations/zipball/4f2d4f2836e7ec4e7a8625e75c6aa916004db931",
+ "reference": "4f2d4f2836e7ec4e7a8625e75c6aa916004db931",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.1 || ^8.0"
+ },
+ "require-dev": {
+ "doctrine/coding-standard": "^9",
+ "phpstan/phpstan": "1.4.10 || 1.10.15",
+ "phpstan/phpstan-phpunit": "^1.0",
+ "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5",
+ "psalm/plugin-phpunit": "0.18.4",
+ "psr/log": "^1 || ^2 || ^3",
+ "vimeo/psalm": "4.30.0 || 5.12.0"
+ },
+ "suggest": {
+ "psr/log": "Allows logging deprecations via PSR-3 logger implementation"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Doctrine\\Deprecations\\": "lib/Doctrine/Deprecations"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "description": "A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all deprecations or selectively for packages.",
+ "homepage": "https://www.doctrine-project.org/",
+ "support": {
+ "issues": "https://github.com/doctrine/deprecations/issues",
+ "source": "https://github.com/doctrine/deprecations/tree/1.1.2"
+ },
+ "time": "2023-09-27T20:04:15+00:00"
+ },
{
"name": "doctrine/instantiator",
- "version": "1.4.0",
+ "version": "1.5.0",
"source": {
"type": "git",
"url": "https://github.com/doctrine/instantiator.git",
- "reference": "d56bf6102915de5702778fe20f2de3b2fe570b5b"
+ "reference": "0a0fa9780f5d4e507415a065172d26a98d02047b"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/doctrine/instantiator/zipball/d56bf6102915de5702778fe20f2de3b2fe570b5b",
- "reference": "d56bf6102915de5702778fe20f2de3b2fe570b5b",
+ "url": "https://api.github.com/repos/doctrine/instantiator/zipball/0a0fa9780f5d4e507415a065172d26a98d02047b",
+ "reference": "0a0fa9780f5d4e507415a065172d26a98d02047b",
"shasum": ""
},
"require": {
"php": "^7.1 || ^8.0"
},
"require-dev": {
- "doctrine/coding-standard": "^8.0",
+ "doctrine/coding-standard": "^9 || ^11",
"ext-pdo": "*",
"ext-phar": "*",
- "phpbench/phpbench": "^0.13 || 1.0.0-alpha2",
- "phpstan/phpstan": "^0.12",
- "phpstan/phpstan-phpunit": "^0.12",
- "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0"
+ "phpbench/phpbench": "^0.16 || ^1",
+ "phpstan/phpstan": "^1.4",
+ "phpstan/phpstan-phpunit": "^1",
+ "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5",
+ "vimeo/psalm": "^4.30 || ^5.4"
},
"type": "library",
"autoload": {
"constructor",
"instantiate"
],
+ "support": {
+ "issues": "https://github.com/doctrine/instantiator/issues",
+ "source": "https://github.com/doctrine/instantiator/tree/1.5.0"
+ },
"funding": [
{
"url": "https://www.doctrine-project.org/sponsorship.html",
"type": "tidelift"
}
],
- "time": "2020-11-10T18:47:58+00:00"
+ "time": "2022-12-30T00:15:36+00:00"
},
{
"name": "myclabs/deep-copy",
- "version": "1.10.2",
+ "version": "1.11.1",
"source": {
"type": "git",
"url": "https://github.com/myclabs/DeepCopy.git",
- "reference": "776f831124e9c62e1a2c601ecc52e776d8bb7220"
+ "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/776f831124e9c62e1a2c601ecc52e776d8bb7220",
- "reference": "776f831124e9c62e1a2c601ecc52e776d8bb7220",
+ "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/7284c22080590fb39f2ffa3e9057f10a4ddd0e0c",
+ "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c",
"shasum": ""
},
"require": {
"php": "^7.1 || ^8.0"
},
- "replace": {
- "myclabs/deep-copy": "self.version"
+ "conflict": {
+ "doctrine/collections": "<1.6.8",
+ "doctrine/common": "<2.13.3 || >=3,<3.2.2"
},
"require-dev": {
- "doctrine/collections": "^1.0",
- "doctrine/common": "^2.6",
- "phpunit/phpunit": "^7.1"
+ "doctrine/collections": "^1.6.8",
+ "doctrine/common": "^2.13.3 || ^3.2.2",
+ "phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13"
},
"type": "library",
"autoload": {
- "psr-4": {
- "DeepCopy\\": "src/DeepCopy/"
- },
"files": [
"src/DeepCopy/deep_copy.php"
- ]
+ ],
+ "psr-4": {
+ "DeepCopy\\": "src/DeepCopy/"
+ }
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"object",
"object graph"
],
+ "support": {
+ "issues": "https://github.com/myclabs/DeepCopy/issues",
+ "source": "https://github.com/myclabs/DeepCopy/tree/1.11.1"
+ },
"funding": [
{
"url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy",
"type": "tidelift"
}
],
- "time": "2020-11-13T09:40:50+00:00"
+ "time": "2023-03-08T13:26:56+00:00"
},
{
"name": "phar-io/manifest",
}
],
"description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)",
+ "support": {
+ "issues": "https://github.com/phar-io/manifest/issues",
+ "source": "https://github.com/phar-io/manifest/tree/master"
+ },
"time": "2017-03-05T18:14:27+00:00"
},
{
}
],
"description": "Library for handling version information and constraints",
+ "support": {
+ "issues": "https://github.com/phar-io/version/issues",
+ "source": "https://github.com/phar-io/version/tree/master"
+ },
"time": "2017-03-05T17:38:23+00:00"
},
{
"reflection",
"static analysis"
],
+ "support": {
+ "issues": "https://github.com/phpDocumentor/ReflectionCommon/issues",
+ "source": "https://github.com/phpDocumentor/ReflectionCommon/tree/2.x"
+ },
"time": "2020-06-27T09:03:43+00:00"
},
{
}
],
"description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.",
+ "support": {
+ "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues",
+ "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.3.0"
+ },
"time": "2021-10-19T17:43:47+00:00"
},
{
"name": "phpdocumentor/type-resolver",
- "version": "1.6.0",
+ "version": "1.8.0",
"source": {
"type": "git",
"url": "https://github.com/phpDocumentor/TypeResolver.git",
- "reference": "93ebd0014cab80c4ea9f5e297ea48672f1b87706"
+ "reference": "fad452781b3d774e3337b0c0b245dd8e5a4455fc"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/93ebd0014cab80c4ea9f5e297ea48672f1b87706",
- "reference": "93ebd0014cab80c4ea9f5e297ea48672f1b87706",
+ "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/fad452781b3d774e3337b0c0b245dd8e5a4455fc",
+ "reference": "fad452781b3d774e3337b0c0b245dd8e5a4455fc",
"shasum": ""
},
"require": {
- "php": "^7.2 || ^8.0",
- "phpdocumentor/reflection-common": "^2.0"
+ "doctrine/deprecations": "^1.0",
+ "php": "^7.4 || ^8.0",
+ "phpdocumentor/reflection-common": "^2.0",
+ "phpstan/phpdoc-parser": "^1.13"
},
"require-dev": {
"ext-tokenizer": "*",
- "psalm/phar": "^4.8"
+ "phpbench/phpbench": "^1.2",
+ "phpstan/extension-installer": "^1.1",
+ "phpstan/phpstan": "^1.8",
+ "phpstan/phpstan-phpunit": "^1.1",
+ "phpunit/phpunit": "^9.5",
+ "rector/rector": "^0.13.9",
+ "vimeo/psalm": "^4.25"
},
"type": "library",
"extra": {
}
],
"description": "A PSR-5 based resolver of Class names, Types and Structural Element Names",
- "time": "2022-01-04T19:58:01+00:00"
+ "support": {
+ "issues": "https://github.com/phpDocumentor/TypeResolver/issues",
+ "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.8.0"
+ },
+ "time": "2024-01-11T11:49:22+00:00"
},
{
"name": "phpspec/prophecy",
"spy",
"stub"
],
+ "support": {
+ "issues": "https://github.com/phpspec/prophecy/issues",
+ "source": "https://github.com/phpspec/prophecy/tree/v1.10.3"
+ },
"time": "2020-03-05T15:02:03+00:00"
},
+ {
+ "name": "phpstan/phpdoc-parser",
+ "version": "1.25.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/phpstan/phpdoc-parser.git",
+ "reference": "bd84b629c8de41aa2ae82c067c955e06f1b00240"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/bd84b629c8de41aa2ae82c067c955e06f1b00240",
+ "reference": "bd84b629c8de41aa2ae82c067c955e06f1b00240",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.2 || ^8.0"
+ },
+ "require-dev": {
+ "doctrine/annotations": "^2.0",
+ "nikic/php-parser": "^4.15",
+ "php-parallel-lint/php-parallel-lint": "^1.2",
+ "phpstan/extension-installer": "^1.0",
+ "phpstan/phpstan": "^1.5",
+ "phpstan/phpstan-phpunit": "^1.1",
+ "phpstan/phpstan-strict-rules": "^1.0",
+ "phpunit/phpunit": "^9.5",
+ "symfony/process": "^5.2"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "PHPStan\\PhpDocParser\\": [
+ "src/"
+ ]
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "description": "PHPDoc parser with support for nullable, intersection and generic types",
+ "support": {
+ "issues": "https://github.com/phpstan/phpdoc-parser/issues",
+ "source": "https://github.com/phpstan/phpdoc-parser/tree/1.25.0"
+ },
+ "time": "2024-01-04T17:06:16+00:00"
+ },
{
"name": "phpunit/php-code-coverage",
"version": "5.3.2",
"testing",
"xunit"
],
+ "support": {
+ "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues",
+ "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/5.3"
+ },
"time": "2018-04-06T15:36:58+00:00"
},
{
"filesystem",
"iterator"
],
+ "support": {
+ "irc": "irc://irc.freenode.net/phpunit",
+ "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues",
+ "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/1.4.5"
+ },
"time": "2017-11-27T13:52:08+00:00"
},
{
"keywords": [
"template"
],
+ "support": {
+ "issues": "https://github.com/sebastianbergmann/php-text-template/issues",
+ "source": "https://github.com/sebastianbergmann/php-text-template/tree/1.2.1"
+ },
"time": "2015-06-21T13:50:34+00:00"
},
{
"keywords": [
"timer"
],
+ "support": {
+ "issues": "https://github.com/sebastianbergmann/php-timer/issues",
+ "source": "https://github.com/sebastianbergmann/php-timer/tree/master"
+ },
"time": "2017-02-26T11:10:40+00:00"
},
{
"keywords": [
"tokenizer"
],
+ "support": {
+ "issues": "https://github.com/sebastianbergmann/php-token-stream/issues",
+ "source": "https://github.com/sebastianbergmann/php-token-stream/tree/master"
+ },
"abandoned": true,
"time": "2017-11-27T05:48:46+00:00"
},
"testing",
"xunit"
],
+ "support": {
+ "issues": "https://github.com/sebastianbergmann/phpunit/issues",
+ "source": "https://github.com/sebastianbergmann/phpunit/tree/6.5.14"
+ },
"time": "2019-02-01T05:22:47+00:00"
},
{
"mock",
"xunit"
],
+ "support": {
+ "issues": "https://github.com/sebastianbergmann/phpunit-mock-objects/issues",
+ "source": "https://github.com/sebastianbergmann/phpunit-mock-objects/tree/5.0.10"
+ },
"abandoned": true,
"time": "2018-08-09T05:50:03+00:00"
},
],
"description": "Looks up which function or method a line of code belongs to",
"homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/",
+ "support": {
+ "issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues",
+ "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/1.0.2"
+ },
"funding": [
{
"url": "https://github.com/sebastianbergmann",
"compare",
"equality"
],
+ "support": {
+ "issues": "https://github.com/sebastianbergmann/comparator/issues",
+ "source": "https://github.com/sebastianbergmann/comparator/tree/master"
+ },
"time": "2018-02-01T13:46:46+00:00"
},
{
"keywords": [
"diff"
],
+ "support": {
+ "issues": "https://github.com/sebastianbergmann/diff/issues",
+ "source": "https://github.com/sebastianbergmann/diff/tree/master"
+ },
"time": "2017-08-03T08:09:46+00:00"
},
{
"environment",
"hhvm"
],
+ "support": {
+ "issues": "https://github.com/sebastianbergmann/environment/issues",
+ "source": "https://github.com/sebastianbergmann/environment/tree/master"
+ },
"time": "2017-07-01T08:51:00+00:00"
},
{
"name": "sebastian/exporter",
- "version": "3.1.4",
+ "version": "3.1.5",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/exporter.git",
- "reference": "0c32ea2e40dbf59de29f3b49bf375176ce7dd8db"
+ "reference": "73a9676f2833b9a7c36968f9d882589cd75511e6"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/0c32ea2e40dbf59de29f3b49bf375176ce7dd8db",
- "reference": "0c32ea2e40dbf59de29f3b49bf375176ce7dd8db",
+ "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/73a9676f2833b9a7c36968f9d882589cd75511e6",
+ "reference": "73a9676f2833b9a7c36968f9d882589cd75511e6",
"shasum": ""
},
"require": {
"export",
"exporter"
],
+ "support": {
+ "issues": "https://github.com/sebastianbergmann/exporter/issues",
+ "source": "https://github.com/sebastianbergmann/exporter/tree/3.1.5"
+ },
"funding": [
{
"url": "https://github.com/sebastianbergmann",
"type": "github"
}
],
- "time": "2021-11-11T13:51:24+00:00"
+ "time": "2022-09-14T06:00:17+00:00"
},
{
"name": "sebastian/global-state",
"keywords": [
"global state"
],
+ "support": {
+ "issues": "https://github.com/sebastianbergmann/global-state/issues",
+ "source": "https://github.com/sebastianbergmann/global-state/tree/2.0.0"
+ },
"time": "2017-04-27T15:39:26+00:00"
},
{
],
"description": "Traverses array structures and object graphs to enumerate all referenced objects",
"homepage": "https://github.com/sebastianbergmann/object-enumerator/",
+ "support": {
+ "issues": "https://github.com/sebastianbergmann/object-enumerator/issues",
+ "source": "https://github.com/sebastianbergmann/object-enumerator/tree/3.0.4"
+ },
"funding": [
{
"url": "https://github.com/sebastianbergmann",
],
"description": "Allows reflection of object attributes, including inherited and non-public ones",
"homepage": "https://github.com/sebastianbergmann/object-reflector/",
+ "support": {
+ "issues": "https://github.com/sebastianbergmann/object-reflector/issues",
+ "source": "https://github.com/sebastianbergmann/object-reflector/tree/1.1.2"
+ },
"funding": [
{
"url": "https://github.com/sebastianbergmann",
],
"description": "Provides functionality to recursively process PHP variables",
"homepage": "http://www.github.com/sebastianbergmann/recursion-context",
+ "support": {
+ "issues": "https://github.com/sebastianbergmann/recursion-context/issues",
+ "source": "https://github.com/sebastianbergmann/recursion-context/tree/3.0.1"
+ },
"funding": [
{
"url": "https://github.com/sebastianbergmann",
],
"description": "Provides a list of PHP built-in functions that operate on resources",
"homepage": "https://www.github.com/sebastianbergmann/resource-operations",
+ "support": {
+ "issues": "https://github.com/sebastianbergmann/resource-operations/issues",
+ "source": "https://github.com/sebastianbergmann/resource-operations/tree/master"
+ },
"time": "2015-07-28T20:34:47+00:00"
},
{
],
"description": "Library that helps with managing the version number of Git-hosted PHP projects",
"homepage": "https://github.com/sebastianbergmann/version",
- "time": "2016-10-03T07:35:21+00:00"
- },
- {
- "name": "symfony/polyfill-ctype",
- "version": "v1.24.0",
- "source": {
- "type": "git",
- "url": "https://github.com/symfony/polyfill-ctype.git",
- "reference": "30885182c981ab175d4d034db0f6f469898070ab"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/30885182c981ab175d4d034db0f6f469898070ab",
- "reference": "30885182c981ab175d4d034db0f6f469898070ab",
- "shasum": ""
- },
- "require": {
- "php": ">=7.1"
- },
- "provide": {
- "ext-ctype": "*"
- },
- "suggest": {
- "ext-ctype": "For best performance"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-main": "1.23-dev"
- },
- "thanks": {
- "name": "symfony/polyfill",
- "url": "https://github.com/symfony/polyfill"
- }
+ "support": {
+ "issues": "https://github.com/sebastianbergmann/version/issues",
+ "source": "https://github.com/sebastianbergmann/version/tree/master"
},
- "autoload": {
- "files": [
- "bootstrap.php"
- ],
- "psr-4": {
- "Symfony\\Polyfill\\Ctype\\": ""
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Gert de Pagter",
- "email": "BackEndTea@gmail.com"
- },
- {
- "name": "Symfony Community",
- "homepage": "https://symfony.com/contributors"
- }
- ],
- "description": "Symfony polyfill for ctype functions",
- "homepage": "https://symfony.com",
- "keywords": [
- "compatibility",
- "ctype",
- "polyfill",
- "portable"
- ],
- "funding": [
- {
- "url": "https://symfony.com/sponsor",
- "type": "custom"
- },
- {
- "url": "https://github.com/fabpot",
- "type": "github"
- },
- {
- "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
- "type": "tidelift"
- }
- ],
- "time": "2021-10-20T20:35:02+00:00"
+ "time": "2016-10-03T07:35:21+00:00"
},
{
"name": "theseer/tokenizer",
- "version": "1.2.1",
+ "version": "1.2.2",
"source": {
"type": "git",
"url": "https://github.com/theseer/tokenizer.git",
- "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e"
+ "reference": "b2ad5003ca10d4ee50a12da31de12a5774ba6b96"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/theseer/tokenizer/zipball/34a41e998c2183e22995f158c581e7b5e755ab9e",
- "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e",
+ "url": "https://api.github.com/repos/theseer/tokenizer/zipball/b2ad5003ca10d4ee50a12da31de12a5774ba6b96",
+ "reference": "b2ad5003ca10d4ee50a12da31de12a5774ba6b96",
"shasum": ""
},
"require": {
}
],
"description": "A small library for converting tokenized PHP source code into XML and potentially other formats",
+ "support": {
+ "issues": "https://github.com/theseer/tokenizer/issues",
+ "source": "https://github.com/theseer/tokenizer/tree/1.2.2"
+ },
"funding": [
{
"url": "https://github.com/theseer",
"type": "github"
}
],
- "time": "2021-07-28T10:34:58+00:00"
+ "time": "2023-11-20T00:12:19+00:00"
},
{
"name": "webmozart/assert",
- "version": "1.10.0",
+ "version": "1.11.0",
"source": {
"type": "git",
"url": "https://github.com/webmozarts/assert.git",
- "reference": "6964c76c7804814a842473e0c8fd15bab0f18e25"
+ "reference": "11cb2199493b2f8a3b53e7f19068fc6aac760991"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/webmozarts/assert/zipball/6964c76c7804814a842473e0c8fd15bab0f18e25",
- "reference": "6964c76c7804814a842473e0c8fd15bab0f18e25",
+ "url": "https://api.github.com/repos/webmozarts/assert/zipball/11cb2199493b2f8a3b53e7f19068fc6aac760991",
+ "reference": "11cb2199493b2f8a3b53e7f19068fc6aac760991",
"shasum": ""
},
"require": {
- "php": "^7.2 || ^8.0",
- "symfony/polyfill-ctype": "^1.8"
+ "ext-ctype": "*",
+ "php": "^7.2 || ^8.0"
},
"conflict": {
"phpstan/phpstan": "<0.12.20",
"check",
"validate"
],
- "time": "2021-03-09T10:59:23+00:00"
+ "support": {
+ "issues": "https://github.com/webmozarts/assert/issues",
+ "source": "https://github.com/webmozarts/assert/tree/1.11.0"
+ },
+ "time": "2022-06-03T18:03:27+00:00"
}
],
"aliases": [],
"prefer-lowest": false,
"platform": [],
"platform-dev": [],
- "plugin-api-version": "1.1.0"
+ "plugin-api-version": "2.3.0"
}
--- /dev/null
+#!/bin/sh
+
+# Cleans up all created files to start from scratch
+
+echo "$0: Cleaning up database ..."
+rm -f db/*/*.serial*
+rm -f db/*.cache
+
+echo "$0: All done."
+exit 0
#!/bin/sh
# Really lame ...
-find */ -type f -print0 | xargs -0 sed -i 's/2022 Core/2022 Core/g'
+find */ -type f -print0 | xargs -0 sed -i 's/2023 Core/2023 Core/g'
+++ /dev/null
-Deny from all
+++ /dev/null
-Deny from all
--- /dev/null
+scrypt
+Dominic Black
\ No newline at end of file
--- /dev/null
+Original Scrypt Implementation;
+ Copyright (c) 2009 Colin Percival
+
+PHP Module;
+ Copyright (c) 2012, Dominic Black
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--- /dev/null
+PHP scrypt module
+=================
+
+[![Build Status](https://travis-ci.org/DomBlack/php-scrypt.svg?branch=master)](https://travis-ci.org/DomBlack/php-scrypt)
+
+This is a PHP library providing a wrapper to [Colin Percival's scrypt implementation](http://www.tarsnap.com/scrypt.html). Scrypt is a key derivation function designed to be far more secure against hardware brute-force attacks than alternative functions such as PBKDF2 or bcrypt.
+
+Details of the scrypt key derivation function are given in a paper by Colin Percival, Stronger Key Derivation via Sequential Memory-Hard Functions: [PDF](http://www.tarsnap.com/scrypt/scrypt-slides.pdf).
+
+An example class using this module can be found in; scrypt.php
+
+Join in!
+--------
+
+We are happy to receive bug reports, fixes, documentation enhancements, and other improvements.
+
+Please report bugs via the [github issue tracker](http://github.com/DomBlack/php-scrypt/issues).
+
+Master [git repository](https://github.com/DomBlack/php-scrypt):
+
+ git clone git://github.com/DomBlack/php-scrypt.git
+
+Authors
+-------
+
+This library is written and maintained by Dominic Black, <thephenix@gmail.com>.
+
+----
+
+PECL Install
+============
+
+This extension is now avaible through PECL.
+
+```
+pecl install scrypt
+```
+
+Build From Source
+=================
+
+Unix/OSX
+--------
+
+1. `phpize`
+2. If on OSX; `export CFLAGS='-arch i386 -arch x86_64'`
+3. `./configure --enable-scrypt`
+4. `make`
+5. `make install`
+6. Add the extension to your php.ini
+
+````
+ ; Enable scrypt extension module
+ extension=scrypt.so
+````
+
+Windows
+-------
+
+Using Visual Studio 2008 (or Visual C++ Express 2008) open up the attached project
+inside the VS2008 folder. This project assumes you have the PHP thread safe source at;
+`C:\phpsrcts\`, a PHP install at `C:\php\` and this source code extracted to
+`C:\php-scrypt\`.
+
+1. Build the project.
+2. Copy the resultant `scrypt.dll` to your ext directory in PHP.
+3. Add the extension to your php.ini
+
+````
+ ; Enable scrypt extension module
+ extension=scrypt.dll
+````
+
+Legal Stuff
+===========
+This works is licensed under the BSD 2-Clause license.
+
+Original Scrypt Implementation;
+ Copyright (c) 2009 Colin Percival
+
+PHP Module;
+ Copyright (c) 2012, Dominic Black
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
use Org\Mxchange\CoreFramework\Console\Tools\ConsoleTools;
use Org\Mxchange\CoreFramework\EntryPoint\ApplicationEntryPoint;
use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Generic\NullPointerException;
use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
use Org\Mxchange\CoreFramework\Localization\ManageableLanguage;
use Org\Mxchange\CoreFramework\Manager\ManageableApplication;
use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
use Org\Mxchange\CoreFramework\Request\Requestable;
use Org\Mxchange\CoreFramework\Response\Responseable;
use Org\Mxchange\CoreFramework\Utils\Strings\StringUtils;
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
*/
public static function isReachableFilePath (SplFileInfo $fileInstance) {
// Is not reachable by default
+ //* NOISY-DEBUG: */ printf('[%s:%d]: fileInstance=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, get_class($fileInstance));
$isReachable = false;
// Get open_basedir parameter
$openBaseDir = trim(ini_get('open_basedir'));
// Is it set?
+ //* NOISY-DEBUG: */ printf('[%s:%d]: openBaseDir=%s' . PHP_EOL, __METHOD__, __LINE__, $openBaseDir);
if (!empty($openBaseDir)) {
// Check all entries
foreach (explode(PATH_SEPARATOR, $openBaseDir) as $dir) {
// Check on existence
+ //* NOISY-DEBUG: */ printf('[%s:%d]: dir=%s' . PHP_EOL, __METHOD__, __LINE__, $dir);
if (substr($fileInstance->getPathname(), 0, strlen($dir)) == $dir) {
// Is reachable
$isReachable = true;
// Abort lookup as it has been found in open_basedir
+ //* NOISY-DEBUG: */ printf('[%s:%d]: BREAK!' . PHP_EOL, __METHOD__, __LINE__);
break;
}
}
} else {
// If open_basedir is not set, all is allowed
+ //* NOISY-DEBUG: */ printf('[%s:%d]: All is allowed - BREAK!' . PHP_EOL, __METHOD__, __LINE__);
$isReachable = true;
}
// Return status
+ //* NOISY-DEBUG: */ printf('[%s:%d]: isReachable=%d - EXIT' . PHP_EOL, __METHOD__, __LINE__, intval($isReachable));
return $isReachable;
}
* @return $isReadable Whether the file is readable (and therefor exists)
*/
public static function isReadableFile (SplFileInfo $fileInstance) {
- // Default is not readable
- $isReadable = false;
-
// Check if it is a file and readable
+ //* NOISY-DEBUG: */ printf('[%s:%d]: fileInstance=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, get_class($fileInstance));
$isReadable = (
(
self::isReachableFilePath($fileInstance)
);
// Return status
+ //* NOISY-DEBUG: */ printf('[%s:%d]: isReadable=%d - EXIT!' . PHP_EOL, __METHOD__, __LINE__, intval($isReadable));
return $isReadable;
}
*/
public static function loadInclude (SplFileInfo $fileInstance) {
// Should be there ...
- //* NOISY-DEBUG: */ printf('[%s:%d]: fileInstance=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $fileInstance);
+ //* NOISY-DEBUG: */ printf('[%s:%d]: fileInstance=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $fileInstance->__toString());
if (!self::isReadableFile($fileInstance)) {
// Abort here
throw new InvalidArgumentException(sprintf('Cannot find fileInstance.pathname=%s.', $fileInstance->getPathname()));
+ } elseif (!$fileInstance->isFile()) {
+ // Not a file
+ throw new InvalidArgumentException(sprintf('fileInstance.pathname=%s is not a file', $fileInstance->getPathname()));
+ } elseif (substr($fileInstance->__toString(), -4, 4) != '.php') {
+ // Not PHP script
+ throw new InvalidArgumentException(sprintf('fileInstance.pathname=%s is not a PHP script', $fileInstance->getPathname()));
}
// Load it
* 1) Load class loader and scan framework classes, interfaces and
* exceptions.
*/
+ //* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__);
self::scanFrameworkClasses();
/*
* found, continue below with next step.
*/
self::validateApplicationParameter();
+
+ // Trace message
+ //* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__);
}
/**
* Now check and load all files, found deprecated files will throw a
* warning at the user.
*/
+ //* NOISY-DEBUG: */ printf('[%s:%d]: self::configAppIncludes()=%d - CALLED!' . PHP_EOL, __METHOD__, __LINE__, count(self::$configAppIncludes));
foreach (self::$configAppIncludes as $fileName => $status) {
// Construct file instance
+ //* NOISY-DEBUG: */ printf('[%s:%d]: fileName=%s,status=%s' . PHP_EOL, __METHOD__, __LINE__, $fileName, $status);
$fileInstance = new SplFileInfo(sprintf('%s%s.php', self::getDetectedApplicationPath(), $fileName));
// Determine if this file is wanted/readable/deprecated
ApplicationEntryPoint::exitApplication(sprintf('File "%s.php" from application "%s" cannot be read. Please fix CHMOD.', $fileInstance->getBasename(), self::getDetectedApplicationName()));
} elseif (($status != 'required') && (!self::isReadableFile($fileInstance))) {
// Not found but optional/deprecated file, skip it
+ //* NOISY-DEBUG: */ printf('[%s:%d]: fileName=%s,status=%s - SKIPPED!' . PHP_EOL, __METHOD__, __LINE__, $fileName, $status);
continue;
}
}
// Load it
+ //* NOISY-DEBUG: */ printf('[%s:%d]: Invoking self::loadInclude(%s) ...' . PHP_EOL, __METHOD__, __LINE__, $fileInstance->__toString());
self::loadInclude($fileInstance);
}
// Scan for application's classes, exceptions and interfaces
ClassLoader::scanApplicationClasses();
+
+ // Trace message
+ //* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__);
}
/**
*/
public static function startApplication () {
// Is there an application helper instance?
+ //* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__);
$applicationInstance = call_user_func_array(
- array(
+ [
'Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper', 'getSelfInstance'
- ), []
+ ], []
);
// Some sanity checks
+ //* NOISY-DEBUG: */ printf('[%s:%d]: applicationInstance=%s' . PHP_EOL, __METHOD__, __LINE__, $applicationInstance->__toString());
if ((empty($applicationInstance)) || (is_null($applicationInstance))) {
// Something went wrong!
ApplicationEntryPoint::exitApplication(sprintf('[Main:] The application <span class="app_name">%s</span> could not be launched because the helper class <span class="class_name">%s</span> is not loaded.',
}
// Now call all methods in one go
+ //* NOISY-DEBUG: */ printf('[%s:%d]: Initializing application ...' . PHP_EOL, __METHOD__, __LINE__);
foreach (['setupApplicationData', 'initApplication', 'launchApplication'] as $methodName) {
// Call method
- //*NOISY-DEBUG: */ printf('[%s:%d]: Calling methodName=%s ...' . PHP_EOL, __METHOD__, __LINE__, $methodName);
+ //*NOISY-DEBUG: */ printf('[%s:%d]: Invoking methodName=%s ...' . PHP_EOL, __METHOD__, __LINE__, $methodName);
call_user_func([$applicationInstance, $methodName]);
}
+
+ // Trace message
+ //* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__);
}
/**
* Initializes database instance, no need to double-call this method
*
* @return void
+ * @throws BadMethodCallException If this method was invoked twice
*/
public static function initDatabaseInstance () {
// Get application instance
+ //* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__);
$applicationInstance = ApplicationHelper::getSelfInstance();
// Is the database instance already set?
+ //* NOISY-DEBUG: */ printf('[%s:%d]: self::databaseInstance[]=%s' . PHP_EOL, __METHOD__, __LINE__, gettype(self::getDatabaseInstance()));
if (self::getDatabaseInstance() instanceof DatabaseConnector) {
// Yes, then abort here
throw new BadMethodCallException('Method called twice.');
$databaseInstance = ObjectFactory::createObjectByConfiguredName(self::getConfigurationInstance()->getConfigEntry('database_type') . '_class');
// Prepare database instance
- $connectionInstance = DatabaseConnection::createDatabaseConnection(DebugMiddleware::getSelfInstance(), $databaseInstance);
+ $connectionInstance = DatabaseConnection::createDatabaseConnection($databaseInstance);
// Set it in application helper
+ //* NOISY-DEBUG: */ printf('[%s:%d]: Setting connectionInstance=%s ...' . PHP_EOL, __METHOD__, __LINE__, $connectionInstance->__toString());
self::setDatabaseInstance($connectionInstance);
+
+ // Trace message
+ //* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__);
}
/**
*/
public static function detectServerAddress () {
// Is the entry set?
+ //* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__);
if (!isset(self::$serverAddress)) {
// Is it set in $_SERVER?
if (!empty($_SERVER['SERVER_ADDR'])) {
// Set it from $_SERVER
+ //* NOISY-DEBUG: */ printf('[%s:%d]: Setting self::serverAddress=%s from SERVER_ADDR ...' . PHP_EOL, __METHOD__, __LINE__, $_SERVER['SERVER_ADDR']);
self::$serverAddress = $_SERVER['SERVER_ADDR'];
} elseif (isset($_SERVER['SERVER_NAME'])) {
// Resolve IP address
+ //* NOISY-DEBUG: */ printf('[%s:%d]: Resolving SERVER_NAME=%s ...' . PHP_EOL, __METHOD__, __LINE__, $_SERVER['SERVER_NAME']);
$serverIp = ConsoleTools::resolveIpAddress($_SERVER['SERVER_NAME']);
// Is it valid?
+ //* NOISY-DEBUG: */ printf('[%s:%d]: serverId[%s]=%s' . PHP_EOL, __METHOD__, __LINE__, gettype($serverIp), $serverIp);
if ($serverIp === false) {
/*
* Why is gethostbyname() returning the host name and not
}
// Al fine, set it
+ //* NOISY-DEBUG: */ printf('[%s:%d]: Setting self::serverAddress=%s from resolver ...' . PHP_EOL, __METHOD__, __LINE__, $serverAddress);
self::$serverAddress = $serverIp;
} else {
// Run auto-detecting through console tools lib
+ //* NOISY-DEBUG: */ printf('[%s:%d]: Invoking ConsoleTools::acquireSelfIpAddress() ...' . PHP_EOL, __METHOD__, __LINE__);
self::$serverAddress = ConsoleTools::acquireSelfIpAddress();
}
}
// Return it
+ //* NOISY-DEBUG: */ printf('[%s:%d]: self::serverAddress=%s - EXIT!' . PHP_EOL, __METHOD__, __LINE__, self::$serverAddress);
return self::$serverAddress;
}
*/
public static function setDefaultTimezone (string $timezone) {
// Is it set?
+ //* NOISY-DEBUG: */ printf('[%s:%d]: timezone=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $timezone);
if (empty($timezone)) {
// Entry is empty
- throw new InvalidArgumentException('timezone is empty');
+ throw new InvalidArgumentException('Parameter "timezone" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
}
// Default success
$success = date_default_timezone_set($timezone);
// Return status
+ //* NOISY-DEBUG: */ printf('[%s:%d]: success=%d - EXIT!' . PHP_EOL, __METHOD__, __LINE__, intval($success));
return $success;
}
* @todo Test more fields
*/
public static function isHttpSecured () {
+ //* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__);
return (
(
(
*/
public static function detectBaseUrl () {
// Initialize the URL
+ //* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__);
$protocol = 'http';
// Do we have HTTPS?
$baseUrl = sprintf('%s://%s%s', $protocol, self::detectDomain(), self::detectScriptPath());
// Return the URL
+ //* NOISY-DEBUG: */ printf('[%s:%d]: baseUrl=%s - EXIT!' . PHP_EOL, __METHOD__, __LINE__, $baseUrl);
return $baseUrl;
}
*/
public static function detectDomain () {
// Full domain is localnet.invalid by default
+ //* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__);
$fullDomain = 'localnet.invalid';
// Is the server name there?
}
// Return it
+ //* NOISY-DEBUG: */ printf('[%s:%d]: fullDomain=%s - EXIT!' . PHP_EOL, __METHOD__, __LINE__, $fullDomain);
return $fullDomain;
}
*/
public static function detectScriptPath () {
// Default is empty
+ //* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__);
$scriptPath = '';
// Is the scriptname set?
}
// Return it
+ //* NOISY-DEBUG: */ printf('[%s:%d]: scriptPath=%s - EXIT!' . PHP_EOL, __METHOD__, __LINE__, $scriptPath);
return $scriptPath;
}
*/
private static function scanFrameworkClasses () {
// Include class loader
+ //* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__);
require self::getConfigurationInstance()->getConfigEntry('framework_base_path') . 'loader/class_ClassLoader.php';
// Register auto-load function with the SPL
// Scan for all framework classes, exceptions and interfaces
ClassLoader::scanFrameworkClasses();
+
+ // Trace message
+ //* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__);
}
/**
*/
private static function determineRequestType () {
// Determine request type
+ //* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__);
$request = self::getRequestTypeFromSystem();
$requestType = self::getRequestTypeFromSystem();
// Create a new request object
+ //* NOISY-DEBUG: */ printf('[%s:%d]: request=%s,requestType=%s' . PHP_EOL, __METHOD__, __LINE__, $request, $requestType);
$requestInstance = ObjectFactory::createObjectByName(sprintf('Org\Mxchange\CoreFramework\Request\%sRequest', StringUtils::convertToClassName($request)));
// Remember request instance here
+ //* NOISY-DEBUG: */ printf('[%s:%d]: Setting requestInstance=%s ...' . PHP_EOL, __METHOD__, __LINE__, $requestInstance->__toString());
self::setRequestInstance($requestInstance);
// Do we have another response?
}
// ... and a new response object
+ //* NOISY-DEBUG: */ printf('[%s:%d]: request=%s,requestType=%s - AFTER!' . PHP_EOL, __METHOD__, __LINE__, $request, $requestType);
$responseInstance = ObjectFactory::createObjectByName(sprintf('Org\Mxchange\CoreFramework\Response\%sResponse', StringUtils::convertToClassName($request)));
// Remember response instance here
+ //* NOISY-DEBUG: */ printf('[%s:%d]: Setting responseInstance=%s ...' . PHP_EOL, __METHOD__, __LINE__, $responseInstance->__toString());
self::setResponseInstance($responseInstance);
+
+ // Trace message
+ //* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__);
}
/**
*/
private static function validateApplicationParameter () {
// Is the parameter set?
+ //* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__);
if (!self::getRequestInstance()->isRequestElementSet('app')) {
/*
* Don't continue here, the application 'selector' is no longer
$applicationName = self::getRequestInstance()->getRequestElement('app');
// Secure it, by keeping out tags
+ //* NOISY-DEBUG: */ printf('[%s:%d]: applicationName=%s' . PHP_EOL, __METHOD__, __LINE__, $applicationName);
$applicationName = htmlentities(strip_tags($applicationName), ENT_QUOTES);
// Secure it a little more with a reg.exp.
+ //* NOISY-DEBUG: */ printf('[%s:%d]: applicationName=%s' . PHP_EOL, __METHOD__, __LINE__, $applicationName);
$applicationName = preg_replace('/([^a-z0-9_-])+/i', '', $applicationName);
// Construct FQPN (Full-Qualified Path Name) for ApplicationHelper class
+ //* NOISY-DEBUG: */ printf('[%s:%d]: applicationName=%s' . PHP_EOL, __METHOD__, __LINE__, $applicationName);
$applicationPath = sprintf(
'%s%s%s',
self::getConfigurationInstance()->getConfigEntry('application_base_path'),
// Full path for application
// Is the path there? This secures a bit the parameter (from untrusted source).
+ //* NOISY-DEBUG: */ printf('[%s:%d]: applicationPath=%s' . PHP_EOL, __METHOD__, __LINE__, $applicationPath);
if ((!is_dir($applicationPath)) || (!is_readable($applicationPath))) {
// Not found or not readable
ApplicationEntryPoint::exitApplication(sprintf('Application "%s" not found.', $applicationName));
}
// Set the detected application's name and full path for later usage
+ //* NOISY-DEBUG: */ printf('[%s:%d]: Setting applicationPath=%s,applicationName=%s' . PHP_EOL, __METHOD__, __LINE__, $applicationPath, $applicationName);
self::$detectedApplicationPath = $applicationPath;
self::$detectedApplicationName = $applicationName;
+
+ // Trace message
+ //* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__);
}
/**
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// CFG: CODE-TEMPLATE-EXTENSION
$cfg->setConfigEntry('code_template_extension', '.ctp');
-// CFG: SELECTOR-PATH
-$cfg->setConfigEntry('selector_path', 'selector');
-
// CFG: TEMPLATE-BASE-PATH
$cfg->setConfigEntry('tpl_base_path', 'templates/');
// CFG: LANGUAGE-SYSTEM-CLASS
$cfg->setConfigEntry('language_system_class', 'Org\Mxchange\CoreFramework\Localization\LanguageSystem');
-// CFG: SELECTOR-TEMPLATE-PREFIX
-$cfg->setConfigEntry('tpl_selector_prefix', 'selector');
-
// CFG: WEB-CONTENT-TYPE
$cfg->setConfigEntry('web_content_type', 'text/html');
// CFG: META-DESCRIPTION
$cfg->setConfigEntry('meta_description', 'A description for your website');
-// CFG: SELECTOR-MAIN-TEMPLATE
-$cfg->setConfigEntry('selector_main_tpl', 'selector_main');
-
-// CFG: SELECTOR-APPS-TEMPLATE
-$cfg->setConfigEntry('selector_apps_tpl', 'selector_apps');
-
-// CFG: SELECTOR-NAME
-$cfg->setConfigEntry('selector_name', 'selector');
-
-// CFG: DEFAULT-APPLICATION
-$cfg->setConfigEntry('default_application', 'selector');
-
-// CFG: VERBOSE-LEVEL
-$cfg->setConfigEntry('verbose_level', 0);
-
// CFG: CACHE-CLASS
$cfg->setConfigEntry('cache_class', 'Org\Mxchange\CoreFramework\Cache\Memory\MemoryCache');
// CFG: HASH-NORMAL-MASK
$cfg->setConfigEntry('hash_normal_mask', '%1s:%2s'); // 1=salt, 2=plain password/string
-// CFG: IS-SINGLE-SERVER
-$cfg->setConfigEntry('is_single_server', 'Y');
-
// CFG: POST-REGISTRATION-CLASS
$cfg->setConfigEntry('post_registration_class', 'Org\Mxchange\CoreFramework\Action\PostRegistration\Login\LoginAfterRegistrationAction');
// CFG: COOKIE-SSL
$cfg->setConfigEntry('cookie_ssl', FrameworkBootstrap::isHttpSecured());
-// CFG: CRYPT-FIXED-SALT
-$cfg->setConfigEntry('crypt_fixed_salt', 'N');
-
-// CFG: DB-UPDATE-PRIMARY-FORCED
-$cfg->setConfigEntry('db_update_primary_forced', 'Y');
-
// CFG: GERMAN-DATE-TIME
$cfg->setConfigEntry('german_date_time', "%3\$s.%2\$s.%1\$s, %4\$s:%5\$s:%6\$s");
// CFG: COMPRESSOR-CHANNEL-CLASS
$cfg->setConfigEntry('compressor_channel_class', 'Org\Mxchange\CoreFramework\Middleware\Compressor\CompressorChannel');
-// CFG: DEBUG-HTML-OUTPUT-TIMINGS
-$cfg->setConfigEntry('debug_html_output_timings', 'N');
-
-// CFG: DEBUG-CONSOLE-OUTPUT-TIMINGS
-$cfg->setConfigEntry('debug_console_output_timings', 'Y');
-
// CFG: PROXY-HOST
$cfg->setConfigEntry('proxy_host', '');
// CFG: PROXY-PASSWORD
$cfg->setConfigEntry('proxy_password', '');
-// CFG: PROXY-CONNECT-METHOD
-$cfg->setConfigEntry('proxy_connect_method', 'Y');
-
// CFG: HOSTNAME-FILE
$cfg->setConfigEntry('hostname_file', '/etc/hostname');
-// CFG: DATABASE-CACHE-ENABLED
-$cfg->setConfigEntry('database_cache_enabled', false);
-
// CFG: DIRECTORY-CLASS
$cfg->setConfigEntry('directory_class', 'Org\Mxchange\CoreFramework\Filesytem\Pointer\FrameworkDirectoryPointer');
// CFG: FILE-ITERATOR-CLASS
$cfg->setConfigEntry('file_iterator_class', 'Org\Mxchange\CoreFramework\Iterator\File\FileIterator');
-// CFG: FILE-STACK-PRE-ALLOCATE-ENABLED
-$cfg->setConfigEntry('file_stack_pre_allocate_enabled', 'Y');
-
// CFG: FILE-STACK-PRE-ALLOCATE-COUNT
$cfg->setConfigEntry('file_stack_pre_allocate_count', 10000);
// CFG: INDEX-INDEX-CLASS
$cfg->setConfigEntry('file_stack_index_class', 'Org\Mxchange\CoreFramework\Index\File\Stack\FileStackIndex');
-// CFG: INDEX-PRE-ALLOCATE-ENABLED
-$cfg->setConfigEntry('index_pre_allocate_enabled', 'Y');
-
// CFG: INDEX-PRE-ALLOCATE-COUNT
$cfg->setConfigEntry('index_pre_allocate_count', 10000);
// CFG: REGISTRY-ITERATOR-CLASS
$cfg->setConfigEntry('registry_iterator_class', 'Org\Mxchange\CoreFramework\Iterator\Registry\RegistryIterator');
-// CFG: QUIET-DNS-RESOLVER
-$cfg->setConfigEntry('quiet_dns_resolver', false);
-
// CFG: THOUSANDS-SEPARATOR
$cfg->setConfigEntry('thousands_separator', '.');
// CFG: DECIMALS-SEPARATOR
$cfg->setConfigEntry('decimals_separator', ',');
-// CFG: CRYPTO-MCRYPT-STREAM-CLASS
-$cfg->setConfigEntry('crypto_mcrypt_stream_class', 'Org\Mxchange\CoreFramework\Stream\Crypto\Mcrypt\McryptStream');
-
// CFG: CRYPTO-OPENSSL-STREAM-CLASS
$cfg->setConfigEntry('crypto_openssl_stream_class', 'Org\Mxchange\CoreFramework\Stream\Crypto\OpenSsl\OpenSslStream');
// CFG: CRYPTO-NULL-STREAM-CLASS
$cfg->setConfigEntry('crypto_null_stream_class', 'Org\Mxchange\CoreFramework\Stream\Crypto\Null\NullCryptoStream');
-// CFG: DEVELOPER-MODE-ENABLED
-$cfg->setConfigEntry('developer_mode_enabled', true);
-
// CFG: CRYPTO-HASH-FUNCTION-NAME
$cfg->setConfigEntry('crypto_hash_function_name', 'sha256');
+
+/**
+ * -------------------------------------------------------------
+ * Boolean is_*_enabled configuration keys
+ * -------------------------------------------------------------
+ */
+
+// CFG: IS-DEVELOPER-MODE-ENABLED
+$cfg->setConfigEntry('is_developer_mode_enabled', true);
+
+// CFG: IS-DATABASE-CACHE-ENABLED
+$cfg->setConfigEntry('is_database_cache_enabled', false);
+
+// CFG: IS-DEBUG-HTML-OUTPUT-TIMINGS-ENABLED
+$cfg->setConfigEntry('is_debug_html_output_timings_enabled', false);
+
+// CFG: IS-DEBUG-CONSOLE-OUTPUT-TIMINGS-ENABLED
+$cfg->setConfigEntry('is_debug_console_output_timings_enabled', true);
+
+// CFG: IS-REGISTER-EMAIL-UNIQUE-ENABLED
+$cfg->setConfigEntry('is_register_email_unique_enabled', true);
+
+// CFG: IS-BLOCK-SHOWS-REGISTRATION-ENABLED
+$cfg->setConfigEntry('is_block_shows_registration_enabled', true);
+
+// CFG: IS-REGISTER-REQUIRES-EMAIl-ENABLED
+$cfg->setConfigEntry('is_register_requires_email_enabled', true);
+
+// CFG: IS-REGISTER-INCLUDES-PROFILE-ENABLED
+$cfg->setConfigEntry('is_register_includes_profile_enabled', true);
+
+// CFG: IS-REGISTER-PERSONAL-DATA-ENABLED
+$cfg->setConfigEntry('is_register_personal_data_enabled', true);
+
+// CFG: IS-PROFILE-INCLUDES-BIRTHDAY-ENABLED
+$cfg->setConfigEntry('is_profile_includes_birthday_enabled', true);
+
+// CFG: IS-USER-LOGIN-ENABLED
+$cfg->setConfigEntry('is_user_login_enabled', true);
+
+// CFG: IS-GUEST-LOGIN-ENABLED
+$cfg->setConfigEntry('is_guest_login_enabled', true);
+
+// CFG: IS-EMAIL-CHANGE-CONFIRMATION-ENABLED
+$cfg->setConfigEntry('is_email_change_confirmation_enabled', true);
+
+// CFG: IS-EMAIL-CHANGE-ENABLED
+$cfg->setConfigEntry('is_email_change_enabled', true);
+
+// CFG: IS-REFILL-PAGE-ACTIVE-ENABLED
+$cfg->setConfigEntry('is_refill_page_active_enabled', true);
+
+// CFG: IS-PROXY-CONNECT-METHOD-ENABLED
+$cfg->setConfigEntry('is_proxy_connect_method_enabled', true);
+
+// CFG: IS-SINGLE-SERVER-ENABLED
+$cfg->setConfigEntry('is_single_server_enabled', true);
+
+// CFG: IS-CRYPT-FIXED-SALT-ENABLED
+$cfg->setConfigEntry('is_crypt_fixed_salt_enabled', false);
+
+// CFG: IS-DB-UPDATE-PRIMARY-FORCED-ENABLED
+$cfg->setConfigEntry('is_db_update_primary_forced_enabled', true);
+
+// CFG: IS-QUIET-DNS-RESOLVER-ENABLED
+$cfg->setConfigEntry('is_quiet_dns_resolver_enabled', false);
+
+// CFG: IS-FILE-STACK-PRE-ALLOCATE-ENABLED
+$cfg->setConfigEntry('is_file_stack_pre_allocate_enabled', true);
+
+// CFG: IS-INDEX-PRE-ALLOCATE-ENABLED
+$cfg->setConfigEntry('is_index_pre_allocate_enabled', true);
use Org\Mxchange\CoreFramework\Configuration\NoConfigEntryException;
use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
-use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
use Org\Mxchange\CoreFramework\Registry\Registerable;
use Org\Mxchange\CoreFramework\Utils\Strings\StringUtils;
// Import SPL stuff
use \InvalidArgumentException;
+use \UnexpectedValueException;
/**
* A class for the configuration stuff implemented in a singleton design pattern
* @see ClassLoader
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 1.0.1
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
//* NOISY-DEBUG: */ printf('[%s:%d]: configKey=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $configKey);
if (empty($configKey)) {
// Entry is empty
- throw new InvalidArgumentException('Parameter "configKey" is empty', self::EXCEPTION_CONFIG_KEY_IS_EMPTY);
+ throw new InvalidArgumentException('Parameter "configKey" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
}
// Is it set?
//* NOISY-DEBUG: */ printf('[%s:%d]: configKey=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $configKey);
if (empty($configKey)) {
// Entry is empty
- throw new InvalidArgumentException('Parameter "configKey" is empty', self::EXCEPTION_CONFIG_KEY_IS_EMPTY);
+ throw new InvalidArgumentException('Parameter "configKey" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
}
// Convert dashes to underscore
- $configKey = StringUtils::convertDashesToUnderscores($configKey);
+ $configKey = str_replace('-', '_', $configKey);
// Is a valid configuration key provided?
//* NOISY-DEBUG: */ printf('[%s:%d]: configKey=%s - AFTER!' . PHP_EOL, __METHOD__, __LINE__, $configKey);
*/
public final function setConfigEntry (string $configKey, $configValue) {
// Is a valid configuration key key provided?
- //* NOISY-DEBUG: */ printf('[%s:%d]: configKey=%s,configValue[]=%s' . PHP_EOL, __METHOD__, __LINE__, $configKey, gettype($configValue));
+ //* NOISY-DEBUG: */ printf('[%s:%d]: configKey=%s,configValue[]=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $configKey, gettype($configValue));
if (empty($configKey)) {
// Entry is empty
- throw new InvalidArgumentException('Parameter "configKey" is empty', self::EXCEPTION_CONFIG_KEY_IS_EMPTY);
+ throw new InvalidArgumentException('Parameter "configKey" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif ((is_array($configValue)) || (is_object($configValue)) || (is_resource($configValue))) {
// These cannot be set as this is not intended for configuration values, please use FrameworkArrayObject instead.
throw new InvalidArgumentException(sprintf('configValue[]=%s for configKey=%s is not supported.', gettype($configValue), $configKey), self::EXCEPTION_CONFIG_VALUE_TYPE_UNSUPPORTED);
}
// Cast to string
- $configKey = StringUtils::convertDashesToUnderscores($configKey);
+ $configKey = str_replace('-', '_', $configKey);
// Set the configuration value
- //* NOISY-DEBUG: */ printf('[%s:%d]: configKey=%s,configValue[%s]=%s' . PHP_EOL, __METHOD__, __LINE__, $configKey, gettype($configValue), $configValue);
+ //* NOISY-DEBUG: */ printf('[%s:%d]: Setting configKey=%s,configValue[%s]=%s - EXIT!' . PHP_EOL, __METHOD__, __LINE__, $configKey, gettype($configValue), $configValue);
self::$configData[$configKey] = $configValue;
}
//* NOISY-DEBUG: */ printf('[%s:%d]: configKey=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $configKey);
if (empty($configKey)) {
// Entry is empty
- throw new InvalidArgumentException('Parameter "configKey" is empty', self::EXCEPTION_CONFIG_KEY_IS_EMPTY);
+ throw new InvalidArgumentException('Parameter "configKey" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
}
// Convert dashes to underscore
- $configKey = StringUtils::convertDashesToUnderscores($configKey);
+ $configKey = str_replace('-', '_', $configKey);
// Is the configuration key there?
//* NOISY-DEBUG: */ printf('[%s:%d]: configKey=%s - AFTER!' . PHP_EOL, __METHOD__, __LINE__, $configKey);
//* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__);
}
+ /**
+ * Checks if a configuration entry is_*_enabled set to 'Y'
+ *
+ * @param $keyPart Configuration to expand with is_$keyPart_enabled
+ * @return $enabled Whether it has been set to Y or N
+ * @throws InvalidArgumentException If a parameter is invalid
+ * @throws UnexpectedValueException If a returned value is of an unexpected type or value
+ */
+ public function isEnabled (string $keyPart) {
+ // Validate parameters
+ //* NOISY-DEBUG: */ printf('[%s:%d]: keyPart=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $keyPart);
+ if (empty($keyPart)) {
+ // Entry is empty
+ throw new InvalidArgumentException('Parameter "keyPart" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
+ // Construct final config key
+ $configKey = sprintf('is_%s_enabled', $keyPart);
+
+ // Get value from it
+ //* NOISY-DEBUG: */ printf('[%s:%d]: configKey=%s' . PHP_EOL, __METHOD__, __LINE__, $configKey);
+ $isEnabled = $this->getConfigEntry($configKey);
+
+ // Is it Y/N?
+ //* NOISY-DEBUG: */ printf('[%s:%d]: isEnabled[]=%s' . PHP_EOL, __METHOD__, __LINE__, gettype($isEnabled));
+ if (!is_bool($isEnabled)) {
+ // Throw exception
+ throw new UnexpectedValueException(sprintf('isEnabled[]=%s is unexpected', gettype($isEnabled)), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
+ }
+
+ // Return it
+ //* NOISY-DEBUG: */ printf('[%s:%d]: isEnabled=%d - EXIT!' . PHP_EOL, __METHOD__, __LINE__, intval($isEnabled));
+ return $isEnabled;
+ }
+
/**
* Generates a code for hashes from this class
*
*/
public final function getField (string $fieldName) {
// The super interface "FrameworkInterface" requires this
- throw new UnsupportedOperationException(array($this, __FUNCTION__), BaseFrameworkSystem::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
*/
public function isFieldSet (string $fieldName) {
// The super interface "FrameworkInterface" requires this
- throw new UnsupportedOperationException(array($this, __FUNCTION__), BaseFrameworkSystem::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
}
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
*
* This program is free software: you can redistribute it and/or modify
// Import framework stuff
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
// Import SPL stuff
use \InvalidArgumentException;
use \RecursiveDirectoryIterator;
use \RecursiveIteratorIterator;
use \SplFileInfo;
+use \UnexpectedValueException;
/**
* This class loads class include files with a specific prefix and suffix
*
* @author Roland Haeder <webmaster@shipsimu.org>
- * @version 1.6.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @version 1.7.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* ----------------------------------
+ * 1.7.0
+ * - "Cached" more like config instance and root/application base path for
+ * shorter call stacks and lesser methods invoked
+ * - More debug logging
* 1.6.0
* - This class loader is now 100% singleton, no other instance is really
* required, therefore the factory method can be removed safely
private static $selfInstance = NULL;
/**
- * Cached configuration entry 'developer_mode_enabled'
+ * Instance of a FrameworkConfiguration class
*/
- private static $developerModeEnabled = false;
+ private static $configInstance = NULL;
+
+ /**
+ * Cached configuration entry 'is_developer_mode_enabled'
+ */
+ private static $developerModeEnabled = NULL;
/**
* Array with all valid but pending for loading file names (class,
*/
private static $testPaths = [];
+ /**
+ * Cached includes that needs to be flushed
+ */
+ private $flushCache = [];
+
/**
* The protected constructor. Please use the factory method below, or use
* getSelfInstance() for singleton
* @return void
*/
private function __construct () {
- // Cache config entry
- self::$developerModeEnabled = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('developer_mode_enabled');
+ // Is developerModeEnabled set?
+ //* NOISY-DEBUG: */ printf('[%s:%d]: CONSTRUCTED!' . PHP_EOL, __METHOD__, __LINE__);
+ if (is_null(self::$developerModeEnabled)) {
+ // Cache config instance
+ self::$configInstance = FrameworkBootstrap::getConfigurationInstance();
+
+ // Cache config entry
+ self::$developerModeEnabled = self::$configInstance->isEnabled('developer_mode');
+ }
+
+ // Trace message
+ //* NOISY-DEBUG: */ printf('[%s:%d]: self::developerModeEnabled=%d - EXIT!' . PHP_EOL, __METHOD__, __LINE__, intval(self::$developerModeEnabled));
}
/**
*/
public function __destruct () {
// Skip here if dev-mode
+ //* NOISY-DEBUG: */ printf('[%s:%d]: self::developerModeEnabled=%d - DESTRUCTED!' . PHP_EOL, __METHOD__, __LINE__, intval(self::$developerModeEnabled));
if (self::$developerModeEnabled) {
+ // Is enabled, don't cache
+ //* NOISY-DEBUG: */ printf('[%s:%d]: Developer mode enabled, not caching classes - EXIT!' . PHP_EOL, __METHOD__, __LINE__);
return;
}
+ // Init content
+ $cacheContent = '';
+
// Skip here if already cached
+ //* NOISY-DEBUG: */ printf('[%s:%d]: this->listCached=%d' . PHP_EOL, __METHOD__, __LINE__, intval($this->listCached));
if ($this->listCached === false) {
// Writes the cache file of our list away
$cacheContent = json_encode($this->pendingFiles);
// Open cache instance
+ //* NOISY-DEBUG: */ printf('[%s:%d]: cacheContent()=%d' . PHP_EOL, __METHOD__, __LINE__, strlen($cacheContent));
$fileObject = $this->listCacheFile->openFile('w');
// And write whole list
$fileObject->fwrite($cacheContent);
+
+ // Close it
+ //* NOISY-DEBUG: */ printf('[%s:%d]: Closing file %s ...' . PHP_EOL, __METHOD__, __LINE__, $fileObject->getPathName());
+ unset($fileObject);
}
+ // Init content
+ $cacheContent = '';
+
// Skip here if already cached
+ //* NOISY-DEBUG: */ printf('[%s:%d]: this->classesCached=%d' . PHP_EOL, __METHOD__, __LINE__, intval($this->classesCached));
if ($this->classesCached === false) {
// Generate a full-cache of all classes
- $cacheContent = '';
- foreach (array_keys($this->loadedClasses) as $fileInstance) {
+ //* NOISY-DEBUG: */ printf('[%s:%d]: this->flushCache()=%d' . PHP_EOL, __METHOD__, __LINE__, count($this->flushCache));
+ foreach ($this->flushCache as $key => $fileInstance) {
// Open file
+ //* NOISY-DEBUG: */ printf('[%s:%d]: key=%s,fileInstance[]=%s' . PHP_EOL, __METHOD__, __LINE__, $key, gettype($fileInstance));
$fileObject = $fileInstance->openFile('r');
// Load the file
// @TODO Add some uglifying code (compress) here
+ //* NOISY-DEBUG: */ printf('[%s:%d]: Adding fileInstance->size=%d bytes ...' . PHP_EOL, __METHOD__, __LINE__, $fileInstance->getSize());
$cacheContent .= $fileObject->fread($fileInstance->getSize());
}
// Open file
+ //* NOISY-DEBUG: */ printf('[%s:%d]: cacheContent()=%d' . PHP_EOL, __METHOD__, __LINE__, strlen($cacheContent));
$fileObject = $this->classCacheFile->openFile('w');
// And write it away
$fileObject->fwrite($cacheContent);
+
+ // Close it
+ //* NOISY-DEBUG: */ printf('[%s:%d]: Closing file %s ...' . PHP_EOL, __METHOD__, __LINE__, $fileObject->getPathName());
+ unset($fileObject);
}
+
+ // Trace message
+ //* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__);
}
/**
$loaderInstance = self::getSelfInstance();
// "Cache" configuration instance and framework base path
- $configInstance = FrameworkBootstrap::getConfigurationInstance();
- $frameworkBasePath = $configInstance->getConfigEntry('framework_base_path');
+ $frameworkBasePath = self::$configInstance->getConfigEntry('framework_base_path');
// Load all classes
//* NOISY-DEBUG: */ printf('[%s:%d]: frameworkBasePath=%s,self::$frameworkPaths()=%d,' . PHP_EOL, __METHOD__, __LINE__, $frameworkBasePath, count(self::$frameworkPaths));
* Scans for application's classes, etc.
*
* @return void
+ * @throws UnexpectedValueException If a given path isn't one or not readable
*/
public static function scanApplicationClasses () {
// Get loader instance
//* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__);
$loaderInstance = self::getSelfInstance();
- // "Cache" configuration instance
- $configInstance = FrameworkBootstrap::getConfigurationInstance();
+ // "Cache" application base path
+ $basePath = self::$configInstance->getConfigEntry('application_base_path');
// Load all classes for the application
+ //* NOISY-DEBUG: */ printf('[%s:%d]: self::frameworkPaths()=%d,basePath=%s' . PHP_EOL, __METHOD__, __LINE__, count(self::$frameworkPaths), $basePath);
foreach (self::$frameworkPaths as $shortPath) {
// Create path name
//* NOISY-DEBUG: */ printf('[%s:%d]: shortPath=%s' . PHP_EOL, __METHOD__, __LINE__, $shortPath);
- $pathName = realpath(sprintf(
+ $realPathName = realpath(sprintf(
'%s%s%s%s%s',
- $configInstance->getConfigEntry('application_base_path'),
+ $basePath,
DIRECTORY_SEPARATOR,
FrameworkBootstrap::getDetectedApplicationName(),
DIRECTORY_SEPARATOR,
$shortPath
));
- // Is the path readable?
- //* NOISY-DEBUG: */ printf('[%s:%d]: pathName[%s]=%s' . PHP_EOL, __METHOD__, __LINE__, gettype($pathName), $pathName);
- if (is_dir($pathName)) {
- // Try to load the application classes
- $loaderInstance->scanClassPath($pathName);
- }
- }
-
- // Trace message
- //* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__);
- }
-
- /**
- * Scans for test classes, etc.
- *
- * @return void
- */
- public static function scanTestsClasses () {
- // "Cache" configuration instance
- //* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__);
- $configInstance = FrameworkBootstrap::getConfigurationInstance();
-
- // Load all classes for the application
- foreach (self::$testPaths as $shortPath) {
- // Construct path name
- //* NOISY-DEBUG: */ printf('[%s:%d]: shortPath=%s' . PHP_EOL, __METHOD__, __LINE__, $shortPath);
- $pathName = sprintf(
- '%s%s%s',
- $configInstance->getConfigEntry('root_base_path'),
- DIRECTORY_SEPARATOR,
- $shortPath
- );
-
- // Try to find it
- //* NOISY-DEBUG: */ printf('[%s:%d]: pathName[%s]=%s - BEFORE!' . PHP_EOL, __METHOD__, __LINE__, gettype($pathName), $pathName);
- $realPathName = realpath($pathName);
-
// Is the path readable?
//* NOISY-DEBUG: */ printf('[%s:%d]: realPathName[%s]=%s - AFTER!' . PHP_EOL, __METHOD__, __LINE__, gettype($realPathName), $realPathName);
- if ((is_dir($realPathName)) && (is_readable($realPathName))) {
- // Try to load the application classes
- ClassLoader::getSelfInstance()->scanClassPath($realPathName);
+ if (!is_string($realPathName)) {
+ // Skip this cone
+ //* NOISY-DEBUG: */ printf('[%s:%d]: realPathName[]=%s - SKIPPED!' . PHP_EOL, __METHOD__, __LINE__, gettype($realPathName));
+ continue;
+ } elseif (!is_dir($realPathName)) {
+ // Is not a directory
+ throw new UnexpectedValueException(sprintf('realPathName=%s is not a directory', $realPathName), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
+ } elseif (!is_readable($realPathName)) {
+ // Not readable
+ throw new UnexpectedValueException(sprintf('realPathName=%s cannot be read from', $realPathName), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
}
+
+ // Try to load the application classes
+ //* NOISY-DEBUG: */ printf('[%s:%d]: Scanning for classes/interfaces at realPathName=%s ...' . PHP_EOL, __METHOD__, __LINE__, $realPathName);
+ $loaderInstance->scanClassPath($realPathName);
}
// Trace message
self::$strictNamingConvention = $strictNamingConvention;
}
- /**
- * Registeres given relative path where test classes reside. For regular
- * framework uses, they should not be loaded (and used).
- *
- * @param $relativePath Relative path to test classes
- * @return void
- * @throws InvalidArgumentException If a parameter is invalid
- */
- public static function registerTestsPath (string $relativePath) {
- // Validate parameter
- if (empty($relativePath)) {
- // Should not be empty
- throw new InvalidArgumentException('Parameter "relativePath" is empty');
- }
-
- // "Register" it
- //* NOISY-DEBUG: */ printf('[%s:%d]: relativePath=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $relativePath);
- self::$testPaths[$relativePath] = $relativePath;
-
- // Trace message
- //* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__);
- }
-
/**
* Autoload-function
*
//* NOISY-DEBUG: */ printf('[%s:%d] className=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $className);
if (empty($className)) {
// Should not be empty
- throw new InvalidArgumentException('Parameter "className" is empty');
+ throw new InvalidArgumentException('Parameter "className" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
}
// The class name MUST be at least Tld\Domain\Project\Package\SomeFooBar so split at them
$classNameParts = explode("\\", $className);
// At least 3 parts should be there
+ //* NOISY-DEBUG: */ printf('[%s:%d]: self::strictNamingConvention=%d,classNameParts()=%d' . PHP_EOL, __METHOD__, __LINE__, intval(self::$strictNamingConvention), count($classNameParts));
if ((self::$strictNamingConvention === true) && (count($classNameParts) < 5)) {
// Namespace scheme is: Tld\Domain\Project\Package[\SubPackage...]
throw new InvalidArgumentException(sprintf('Class name "%s" is not conform to naming-convention: Tld\Domain\Project\Package[\SubPackage...]\SomeFooBar', $className));
}
// Try to include this class
- //* NOISY-DEBUG: */ printf('[%s:%d]: Calling self->loadClassFile(%s) ...' . PHP_EOL, __METHOD__, __LINE__, $className);
+ //* NOISY-DEBUG: */ printf('[%s:%d]: Invoking self->loadClassFile(%s) ...' . PHP_EOL, __METHOD__, __LINE__, $className);
self::getSelfInstance()->loadClassFile($className);
// Trace message
*/
public static final function getSelfInstance () {
// Is the instance there?
+ //* NOISY-DEBUG: */ printf('[%s:%d]: self::selfInstance[]=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, gettype(self::$selfInstance));
if (is_null(self::$selfInstance)) {
// Get a new one and initialize it
+ //* NOISY-DEBUG: */ printf('[%s:%d]: Initializing class loader ...' . PHP_EOL, __METHOD__, __LINE__);
self::$selfInstance = new ClassLoader();
self::$selfInstance->initClassLoader();
}
// Return the instance
+ //* NOISY-DEBUG: */ printf('[%s:%d]: self::selfInstance=%s - EXIT!' . PHP_EOL, __METHOD__, __LINE__, get_class(self::$selfInstance));
return self::$selfInstance;
}
public function getPrintableIncludeList () {
// Prepare the list
$includeList = '';
- foreach ($this->loadedClasses as $classFile) {
+ foreach (array_keys($this->loadedClasses) as $classFile) {
$includeList .= basename($classFile) . '<br />' . PHP_EOL;
}
//* NOISY-DEBUG: */ printf('[%s:%d] basePath=%s,ignoreList()=%d - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $basePath, count($ignoreList));
if (empty($basePath)) {
// Throw IAE
- throw new InvalidArgumentException('Parameter "basePath" is empty');
+ throw new InvalidArgumentException('Parameter "basePath" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif ($this->listCached === true) {
// Abort here
//* NOISY-DEBUG: */ printf('[%s:%d] this->listCache=true - EXIT!' . PHP_EOL, __METHOD__, __LINE__);
* should be used here so is_dir(), is_file() and so on will always
* find the correct files and dirs.
*/
- $basePath2 = realpath($basePath);
+ $basePath = realpath($basePath);
// If the basePath is false it is invalid
- //* NOISY-DEBUG: */ printf('[%s:%d] basePath2[%s]=%s' . PHP_EOL, __METHOD__, __LINE__, gettype($basePath2), $basePath2);
- if ($basePath2 === false) {
+ //* NOISY-DEBUG: */ printf('[%s:%d] basePath[%s]=%s' . PHP_EOL, __METHOD__, __LINE__, gettype($basePath), $basePath);
+ if (!is_string($basePath)) {
/* @TODO: Do not exit here. */
exit(__METHOD__ . ': Cannot read ' . $basePath . ' !' . PHP_EOL);
- } else {
- // Set base path
- $basePath = $basePath2;
}
// Get a new iterator
$currentEntry = $iteratorInstance->current();
// Get filename from iterator which is the class' name (according naming-convention)
+ //* NOISY-DEBUG: */ printf('[%s:%d] currentEntry=%s,currentEntry->size=%d' . PHP_EOL, __METHOD__, __LINE__, $currentEntry->__toString(), $currentEntry->getSize());
$fileName = $currentEntry->getFilename();
// Current entry must be a file, not smaller than 100 bytes and not on ignore list
+ //* NOISY-DEBUG: */ printf('[%s:%d] fileName=%s' . PHP_EOL, __METHOD__, __LINE__, $fileName);
if (!$currentEntry->isFile() || isset($this->ignoreList[$fileName]) || $currentEntry->getSize() < 100) {
// Advance to next entry
$iteratorInstance->next();
* @return void
*/
private function initClassLoader () {
- // Construct the FQFN for the cache
- if (!self::$developerModeEnabled) {
- // Init cache instances
- $this->listCacheFile = new SplFileInfo(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('local_database_path') . 'list-' . FrameworkBootstrap::getDetectedApplicationName() . '.cache');
- $this->classCacheFile = new SplFileInfo(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('local_database_path') . 'class-' . FrameworkBootstrap::getDetectedApplicationName() . '.cache');
- }
-
// Set suffix and prefix from configuration
- $this->suffix = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('class_suffix');
- $this->prefix = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('class_prefix');
+ //* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__);
+ $this->suffix = self::$configInstance->getConfigEntry('class_suffix');
+ $this->prefix = self::$configInstance->getConfigEntry('class_prefix');
// Set own instance
+ //* NOISY-DEBUG: */ printf('[%s:%d]: this->suffix=%s,this->prefix=%s' . PHP_EOL, __METHOD__, __LINE__, $this->suffix, $this->prefix);
self::$selfInstance = $this;
// Skip here if no dev-mode
+ //* NOISY-DEBUG: */ printf('[%s:%d]: self::developerModeEnabled=%d' . PHP_EOL, __METHOD__, __LINE__, intval(self::$developerModeEnabled));
if (self::$developerModeEnabled) {
+ // Developer mode is enabled
+ //* NOISY-DEBUG: */ printf('[%s:%d]: Developer mode is enabled - EXIT!' . PHP_EOL, __METHOD__, __LINE__);
return;
}
+ // Init cache instances
+ //* NOISY-DEBUG: */ printf('[%s:%d]: Initializing cache file instances ...' . PHP_EOL, __METHOD__, __LINE__);
+ $this->listCacheFile = new SplFileInfo(self::$configInstance->getConfigEntry('local_database_path') . 'list-' . FrameworkBootstrap::getDetectedApplicationName() . '.cache');
+ $this->classCacheFile = new SplFileInfo(self::$configInstance->getConfigEntry('local_database_path') . 'class-' . FrameworkBootstrap::getDetectedApplicationName() . '.cache');
+
// Is the cache there?
+ //* NOISY-DEBUG: */ printf('[%s:%d]: Checking this->listCacheFile=%s ...' . PHP_EOL, __METHOD__, __LINE__, $this->listCacheFile);
if (FrameworkBootstrap::isReadableFile($this->listCacheFile)) {
// Load and convert it
+ //* NOISY-DEBUG: */ printf('[%s:%d]: Loading %s ...' . PHP_EOL, __METHOD__, __LINE__, $this->listCacheFile);
$this->pendingFiles = json_decode(file_get_contents($this->listCacheFile->getPathname()));
// List has been restored from cache!
}
// Does the class cache exist?
+ //* NOISY-DEBUG: */ printf('[%s:%d]: Checking this->classCacheFile=%s ...' . PHP_EOL, __METHOD__, __LINE__, $this->classCacheFile);
if (FrameworkBootstrap::isReadableFile($this->classCacheFile)) {
// Then include it
+ //* NOISY-DEBUG: */ printf('[%s:%d]: Invoking FrameworkBootstrap::loadInclude(%s) ...' . PHP_EOL, __METHOD__, __LINE__, $this->classCacheFile);
FrameworkBootstrap::loadInclude($this->classCacheFile);
// Mark the class cache as loaded
$this->classesCached = true;
}
+
+ // Trace message
+ //* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__);
}
/**
*/
private function loadClassFile (string $className) {
// The class name should contain at least 2 back-slashes, so split at them
- //* NOISY-DEBUG: */ printf('[%s:%d] className=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $className);
+ //* NOISY-DEBUG: */ printf('[%s:%d]: className=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $className);
$classNameParts = explode("\\", $className);
// Get last element
+ //* NOISY-DEBUG: */ printf('[%s:%d]: classNameParts()=%d' . PHP_EOL, __METHOD__, __LINE__, count($classNameParts));
$shortClassName = array_pop($classNameParts);
// Create a name with prefix and suffix
+ //* NOISY-DEBUG: */ printf('[%s:%d]: this->prefix=%s,shortClassName=%s,this->suffix=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $this->prefix, $shortClassName, $this->suffix);
$fileName = sprintf('%s%s%s', $this->prefix, $shortClassName, $this->suffix);
// Now look it up in our index
+ //* DEBUG-DIE: */ die(sprintf('[%s:%d]: this->pendingFiles=%s', __METHOD__, __LINE__, print_r($this->pendingFiles, TRUE)));
//* NOISY-DEBUG: */ printf('[%s:%d] ISSET: fileName=%s' . PHP_EOL, __METHOD__, __LINE__, $fileName);
if ((isset($this->pendingFiles[$fileName])) && (!isset($this->loadedClasses[$this->pendingFiles[$fileName]->getPathname()]))) {
// File is found and not loaded so load it only once
$this->total++;
// Mark this class as loaded for other purposes than loading it.
+ //* NOISY-DEBUG: */ printf('[%s:%d] LOAD: fileName=%s marked as loaded ...' . PHP_EOL, __METHOD__, __LINE__, $fileName);
$this->loadedClasses[$this->pendingFiles[$fileName]->getPathname()] = true;
- // Remove it from classes list so it won't be found twice.
- //* NOISY-DEBUG: */ printf('[%s:%d] UNSET: fileName=%s' . PHP_EOL, __METHOD__, __LINE__, $fileName);
- unset($this->pendingFiles[$fileName]);
-
// Developer mode excludes caching (better debugging)
+ //* NOISY-DEBUG: */ printf('[%s:%d] self::developerModeEnabled=%d' . PHP_EOL, __METHOD__, __LINE__, intval(self::$developerModeEnabled));
if (!self::$developerModeEnabled) {
- // Reset cache
- //* NOISY-DEBUG: */ printf('[%s:%d] classesCached=false' . PHP_EOL, __METHOD__, __LINE__);
+ // Reset cache and mark file for flushing
+ //* NOISY-DEBUG: */ printf('[%s:%d] Setting this->classesCached=false ...' . PHP_EOL, __METHOD__, __LINE__);
$this->classesCached = false;
+ $this->flushCache[$fileName] = $this->pendingFiles[$fileName];
}
+
+ // Remove it from classes list so it won't be found twice.
+ //* NOISY-DEBUG: */ printf('[%s:%d] UNSET: fileName=%s' . PHP_EOL, __METHOD__, __LINE__, $fileName);
+ unset($this->pendingFiles[$fileName]);
} else {
// Not found
//* NOISY-DEBUG: */ printf('[%s:%d] 404: fileName=%s' . PHP_EOL, __METHOD__, __LINE__, $fileName);
// Import framework stuff
use Org\Mxchange\CoreFramework\Action\BaseAction;
+use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
/**
* An action for ???
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
* @todo 0% done
*/
public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- $this->partialStub("You have to implement me.");
+ DebugMiddleware::getSelfInstance()->partialStub("You have to implement me.");
}
}
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*/
public static final function createHtmlLoginProfileAction (ActionResolver $resolverInstance) {
// Get a new instance
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('HTML-LOGIN-PROFILE-ACTION: resolverInstance=%s - CALLED!', $resolverInstance->__toString()));
$actionInstance = new HtmlLoginProfileAction();
// Set the resolver instance
$actionInstance->setResolverInstance($resolverInstance);
// Return the instance
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('HTML-LOGIN-PROFILE-ACTION: actionInstance=%s - EXIT!', $actionInstance->__toString()));
return $actionInstance;
}
*/
public function execute (Requestable $requestInstance, Responseable $responseInstance) {
// Dummy method
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('HTML-LOGIN-PROFILE-ACTION: requestInstance=%s,responseInstance=%s - CALLED!', $requestInstance->__toString(), $responseInstance->__toString()));
}
/**
*/
public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
// Add user status filter here
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('HTML-LOGIN-PROFILE-ACTION: controllerInstance=%s,requestInstance=%s - CALLED!', $controllerInstance->__toString(), $requestInstance->__toString()));
$controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_status_filter_class'));
+
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('HTML-LOGIN-PROFILE-ACTION: EXIT!');
}
}
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*/
public static final function createLoginAfterRegistrationAction () {
// Get a new instance
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('LOGIN-REGISTRATION-ACTION: CALLED!');
$actionInstance = new LoginAfterRegistrationAction();
// Return the instance
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('LOGIN-REGISTRATION-ACTION: actionInstance=%s - EXIT!', $actionInstance->__toString()));
return $actionInstance;
}
*/
public function execute (Requestable $requestInstance, Responseable $responseInstance) {
// Get a login class from factory
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('LOGIN-REGISTRATION-ACTION: requestInstance=%s,responseInstance=%s - CALLED!', $requestInstance->__toString(), $responseInstance->__toString()));
$loginInstance = LoginFactory::createLoginObjectByRequest($requestInstance);
// Login the user by the request instance
// Attach error message to the response
$responseInstance->addFatalMessage('failed_login_after_registration');
}
+
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('LOGIN-REGISTRATION-ACTION: EXIT!');
}
}
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @todo Rename to InProgressCache
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
use Org\Mxchange\CoreFramework\Loader\ClassLoader;
use Org\Mxchange\CoreFramework\Manager\ManageableApplication;
use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
+use Org\Mxchange\CoreFramework\Registry\Object\ObjectRegistry;
use Org\Mxchange\CoreFramework\Result\Database\CachedDatabaseResult;
use Org\Mxchange\CoreFramework\State\Stateable;
use Org\Mxchange\CoreFramework\Stream\Output\OutputStreamer;
use Org\Mxchange\CoreFramework\Utils\Strings\StringUtils;
// Import SPL stuff
-use \stdClass;
+use \BadMethodCallException;
use \InvalidArgumentException;
use \ReflectionClass;
use \SplFileInfo;
+use \stdClass;
/**
* The simulator system class is the super class of all other classes. This
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*/
private static $selfInstance = NULL;
+ /**
+ * Debug instance
+ */
+ private static $debugInstance = NULL;
+
/**
* Stub methods
*/
***********************/
// @todo Try to clean these constants up
- const EXCEPTION_IS_NULL_POINTER = 0x001;
const EXCEPTION_IS_NO_OBJECT = 0x002;
const EXCEPTION_IS_NO_ARRAY = 0x003;
const EXCEPTION_MISSING_METHOD = 0x004;
const EXCEPTION_DIR_POINTER_INVALID = 0x019;
const EXCEPTION_FILE_POINTER_INVALID = 0x01a;
const EXCEPTION_INVALID_RESOURCE = 0x01b;
- const EXCEPTION_UNEXPECTED_OBJECT = 0x01c;
const EXCEPTION_LIMIT_ELEMENT_IS_UNSUPPORTED = 0x01d;
const EXCEPTION_GETTER_IS_MISSING = 0x01e;
const EXCEPTION_ARRAY_EXPECTED = 0x01f;
const EXCEPTION_ATTRIBUTES_ARE_MISSING = 0x02b;
const EXCEPTION_ARRAY_ELEMENTS_MISSING = 0x02c;
const EXCEPTION_TEMPLATE_ENGINE_UNSUPPORTED = 0x02d;
- const EXCEPTION_UNSPPORTED_OPERATION = 0x02e;
- const EXCEPTION_FACTORY_REQUIRE_PARAMETER = 0x02f;
- const EXCEPTION_MISSING_ELEMENT = 0x030;
- const EXCEPTION_HEADERS_ALREADY_SENT = 0x031;
- const EXCEPTION_DEFAULT_CONTROLLER_GONE = 0x032;
- const EXCEPTION_CLASS_NOT_FOUND = 0x033;
- const EXCEPTION_REQUIRED_INTERFACE_MISSING = 0x034;
- const EXCEPTION_FATAL_ERROR = 0x035;
- const EXCEPTION_FILE_NOT_FOUND = 0x036;
- const EXCEPTION_ASSERTION_FAILED = 0x037;
- const EXCEPTION_FILE_NOT_REACHABLE = 0x038;
- const EXCEPTION_FILE_CANNOT_BE_READ = 0x039;
- const EXCEPTION_FILE_CANNOT_BE_WRITTEN = 0x03a;
- const EXCEPTION_PATH_CANNOT_BE_WRITTEN = 0x03b;
- const EXCEPTION_DATABASE_UPDATED_NOT_ALLOWED = 0x03c;
- const EXCEPTION_FILTER_CHAIN_INTERCEPTED = 0x03d;
- const EXCEPTION_INVALID_SOCKET = 0x03e;
- const EXCEPTION_SELF_INSTANCE = 0x03f;
+ const EXCEPTION_FACTORY_REQUIRE_PARAMETER = 0x02e;
+ const EXCEPTION_MISSING_ELEMENT = 0x02f;
+ const EXCEPTION_HEADERS_ALREADY_SENT = 0x030;
+ const EXCEPTION_DEFAULT_CONTROLLER_GONE = 0x031;
+ const EXCEPTION_REQUIRED_INTERFACE_MISSING = 0x033;
+ const EXCEPTION_FATAL_ERROR = 0x034;
+ const EXCEPTION_FILE_NOT_FOUND = 0x035;
+ const EXCEPTION_ASSERTION_FAILED = 0x036;
+ const EXCEPTION_FILE_NOT_REACHABLE = 0x037;
+ const EXCEPTION_FILE_CANNOT_BE_READ = 0x038;
+ const EXCEPTION_FILE_CANNOT_BE_WRITTEN = 0x039;
+ const EXCEPTION_PATH_CANNOT_BE_WRITTEN = 0x03a;
+ const EXCEPTION_DATABASE_UPDATED_NOT_ALLOWED = 0x03b;
+ const EXCEPTION_FILTER_CHAIN_INTERCEPTED = 0x03c;
+ const EXCEPTION_INVALID_SOCKET = 0x03d;
+ const EXCEPTION_SELF_INSTANCE = 0x03e;
/**
* Startup time in miliseconds
$this->setRealClass('DestructedObject');
} elseif ((defined('DEBUG_DESTRUCTOR')) && (is_object($this->getDebugInstance()))) {
// Already destructed object
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('The object <span class="object_name">%s</span> is already destroyed.',
+ self::createDebugInstance(__CLASS__, __LINE__)->warningMessage(sprintf('The object <span class="object_name">%s</span> is already destroyed.',
$this->__toString()
));
} else {
// Do not call this twice
trigger_error(__METHOD__ . ': Called twice.');
- exit;
+ exit(255);
}
}
// Output stub message
// @TODO __CLASS__ does always return BaseFrameworkSystem but not the extending (=child) class
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s::%s]: Stub! Args: %s',
+ self::createDebugInstance(__CLASS__, __LINE__)->warningMessage(sprintf('[%s::%s]: Stub! Args: %s',
$className,
$methodName,
$argsString
* @throws UnsupportedOperationException Objects of this framework cannot be serialized
*/
public final function __sleep () {
- throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
* @throws UnsupportedOperationException Objects of this framework cannot be serialized
*/
public final function __wakeup () {
- throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
* @throws UnsupportedOperationException Objects of this framework cannot be serialized
*/
public final function __invoke () {
- throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
* @return void
*/
public final function setDebugInstance (DebugMiddleware $debugInstance) {
- GenericRegistry::getRegistry()->addInstance('debug', $debugInstance);
+ self::$debugInstance = $debugInstance;
}
/**
* @return $debugInstance Instance to class DebugConsoleOutput or DebugWebOutput
*/
public final function getDebugInstance () {
- // Get debug instance
- $debugInstance = GenericRegistry::getRegistry()->getInstance('debug');
-
- // Return it
- return $debugInstance;
+ return self::$debugInstance;
}
/**
* @return void
*/
public final function setWebOutputInstance (OutputStreamer $webInstance) {
- GenericRegistry::getRegistry()->addInstance('web_output', $webInstance);
+ ObjectRegistry::getRegistry('generic')->addInstance('web_output', $webInstance);
}
/**
* @return $webOutputInstance - Instance to class WebOutput
*/
public final function getWebOutputInstance () {
- $webOutputInstance = GenericRegistry::getRegistry()->getInstance('web_output');
- return $webOutputInstance;
+ return ObjectRegistry::getRegistry('generic')->getInstance('web_output');
}
/**
*
* @param $str A string (maybe) without trailing slash
* @return $str A string with an auto-appended trailing slash
+ * @throws InvalidArgumentException If a paramter has an invalid value
*/
public final function addMissingTrailingSlash (string $str) {
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-FRAMEWORK-SYSTEM: str=%s - CALLED!', $str));
+ if (empty($str)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "str" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Is there a trailing slash?
if (substr($str, -1, 1) != '/') {
$str .= '/';
}
// Return string with trailing slash
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-FRAMEWORK-SYSTEM: str=%s - EXIT!', $str));
return $str;
}
*
* @param $message Optional message to show in debug output
* @return void
+ * @throws InvalidArgumentException If a paramter has an invalid value
*/
public final function debugInstance (string $message = '') {
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-FRAMEWORK-SYSTEM: message=%s - CALLED!', $message));
+ if (empty($message)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "message" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Restore the error handler to avoid trouble with missing array elements or undeclared variables
restore_error_handler();
));
}
- /**
- * Output a partial stub message for the caller method
- *
- * @param $message An optional message to display
- * @return void
- */
- protected function partialStub (string $message = '') {
- // Init variable
- $stubMessage = 'Partial stub!';
-
- // Is an extra message given?
- if (!empty($message)) {
- // Then add it as well
- $stubMessage .= ' Message: ' . $message;
- }
-
- // Debug instance is there?
- if (!is_null($this->getDebugInstance())) {
- // Output stub message
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput($stubMessage);
- } else {
- // Trigger an error
- trigger_error($stubMessage);
- exit;
- }
- }
-
/**
* Outputs a debug backtrace and stops further script execution
*
* @param $message An optional message to output
* @param $doExit Whether exit the program (true is default)
* @return void
+ * @throws InvalidArgumentException If a paramter has an invalid value
*/
public function debugBackTrace (string $message = '', bool $doExit = true) {
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-FRAMEWORK-SYSTEM: message=%s,doExit=%d - CALLED!', $message, intval($doExit)));
+ if (empty($message)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "message" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Sorry, there is no other way getting this nice backtrace
if (!empty($message)) {
// Output message
// Exit program?
if ($doExit === true) {
- exit();
+ // Yes, with error code
+ exit(255);
}
}
* @param $className Name of the class (currently unsupported)
* @param $lineNumber Line number where the call was made
* @return $debugInstance An instance of a debugger class
+ * @throws InvalidArgumentException If a parameter has an invalid value
* @deprecated Not fully, as the new Logger facilities are not finished yet.
*/
public final static function createDebugInstance (string $className, int $lineNumber = NULL) {
// Validate parameter
+ //* NOISY-DEBUG: */ printf('[%s:%d]: className=%s,lineNumber[%s]=%d - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $className, gettype($lineNumber), $lineNumber);
if (empty($className)) {
// Throw IAE
- throw new InvalidArgumentException('Parameter "className" is empty');
- } elseif (!GenericRegistry::getRegistry()->instanceExists('debug')) {
+ throw new InvalidArgumentException('Parameter "className" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
+ // Is the debug instance set?
+ //* NOISY-DEBUG: */ printf('[%s:%d]: self::debugInstance[]=%s' . PHP_EOL, __METHOD__, __LINE__, gettype(self::$debugInstance));
+ if (is_null(self::$debugInstance)) {
// Init debug instance
- $debugInstance = NULL;
+ self::$debugInstance = NULL;
// Try it
try {
// Get a debugger instance
- $debugInstance = DebugMiddleware::createDebugMiddleware(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('debug_' . FrameworkBootstrap::getRequestTypeFromSystem() . '_class'), $className);
+ //* NOISY-DEBUG: */ printf('[%s:%d]: className=%s' . PHP_EOL, __METHOD__, __LINE__, $className);
+ self::$debugInstance = DebugMiddleware::createDebugMiddleware(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('debug_' . FrameworkBootstrap::getRequestTypeFromSystem() . '_class'), $className);
} catch (NullPointerException $e) {
// Didn't work, no instance there
exit(sprintf('[%s:%d]: Cannot create debugInstance! Exception=%s,message=%s,className=%s,lineNumber=%d' . PHP_EOL, __METHOD__, __LINE__, $e->__toString(), $e->getMessage(), $className, $lineNumber));
}
-
- // Empty string should be ignored and used for testing the middleware
- DebugMiddleware::getSelfInstance()->output('');
-
- // Set it in registry
- GenericRegistry::getRegistry()->addInstance('debug', $debugInstance);
- } else {
- // Get instance from registry
- $debugInstance = GenericRegistry::getRegistry()->getDebugInstance();
}
// Return it
- return $debugInstance;
+ //* NOISY-DEBUG: */ printf('[%s:%d]: self::debugInstance=%s - EXIT!' . PHP_EOL, __METHOD__, __LINE__, self::$debugInstance->__toString());
+ return self::$debugInstance;
}
/**
*
* @param $message Message to output
* @return void
+ * @throws InvalidArgumentException If a paramter has an invalid value
*/
public function outputLine (string $message) {
- // Simply output it
- print($message . PHP_EOL);
- }
-
- /**
- * Outputs a debug message whether to debug instance (should be set!) or
- * dies with or ptints the message. Do NEVER EVER rewrite the exit() call to
- * ApplicationEntryPoint::app_exit(), this would cause an endless loop.
- *
- * @param $message Message we shall send out...
- * @param $doPrint Whether print or die here (default: print)
- * @paran $stripTags Whether to strip tags (default: false)
- * @return void
- */
- public function debugOutput (string $message, bool $doPrint = true, bool $stripTags = false) {
- // Set debug instance to NULL
- $debugInstance = NULL;
-
- // Get backtrace
- $backtrace = debug_backtrace(!DEBUG_BACKTRACE_PROVIDE_OBJECT);
-
- // Is function partialStub/__callStatic ?
- if (isset(self::$stubMethods[$backtrace[1]['function']])) {
- // Prepend class::function:line from 3rd element
- $message = sprintf('[%s::%s:%d]: %s',
- $backtrace[2]['class'],
- $backtrace[2]['function'],
- (isset($backtrace[2]['line']) ? $backtrace[2]['line'] : '0'),
- $message
- );
- } else {
- // Prepend class::function:line from 2nd element
- $message = sprintf('[%s::%s:%d]: %s',
- $backtrace[1]['class'],
- $backtrace[1]['function'],
- (isset($backtrace[1]['line']) ? $backtrace[1]['line'] : '0'),
- $message
- );
- }
-
- // Try it:
- try {
- // Get debug instance
- $debugInstance = $this->getDebugInstance();
- } catch (NullPointerException $e) {
- // The debug instance is not set (yet)
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-FRAMEWORK-SYSTEM: message=%s - CALLED!', $message));
+ if (empty($message)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "message" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
}
- // Is the debug instance there?
- if (is_object($debugInstance)) {
- // Use debug output handler
- $debugInstance->output($message, $stripTags);
-
- if ($doPrint === false) {
- // Die here if not printed
- exit();
- }
- } else {
- // Are debug times enabled?
- if (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('debug_' . FrameworkBootstrap::getRequestTypeFromSystem() . '_output_timings') == 'Y') {
- // Prepent it
- $message = $this->getPrintableExecutionTime() . $message;
- }
-
- // Put directly out
- if ($doPrint === true) {
- // Print message
- $this->outputLine($message);
- } else {
- // Die here
- exit($message);
- }
- }
+ // Simply output it
+ print($message . PHP_EOL);
}
/**
*
* @param $phpCode Unmarked PHP code
* @return $markedCode Marked PHP code
+ * @throws InvalidArgumentException If a paramter has an invalid value
*/
public function markupCode (string $phpCode) {
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-FRAMEWORK-SYSTEM: phpCode=%s - CALLED!', $phpCode));
+ if (empty($phpCode)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "phpCode" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Init marked code
$markedCode = '';
* @return $entry An array with database entries
* @throws NullPointerException If the database result is not found
* @throws InvalidDatabaseResultException If the database result is invalid
- * @todo Monolithic method, should be moved to proper classes
+ * @deprecated Monolithic method, should be moved to proper classes
*/
protected final function getDatabaseEntry () {
+ // This method is deprecated
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-FRAMEWORK-SYSTEM: CALLED!');
+ $this->deprecationWarning('Monolithic method, should be moved to proper classes');
+
// Is there an instance?
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-FRAMEWORK-SYSTEM: this->resultInstance[]=%s', gettype($this->getResultInstance())));
if (!$this->getResultInstance() instanceof SearchableResult) {
// Throw an exception here
- throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
+ throw new NullPointerException($this, FrameworkInterface::EXCEPTION_IS_NULL_POINTER);
}
// Rewind it
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-FRAMEWORK-SYSTEM: Invoking this->resultInstance->rewind() ...');
$this->getResultInstance()->rewind();
// Do we have an entry?
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-FRAMEWORK-SYSTEM: this->resultInstance->isValid()=%d', intval($this->getResultInstance()->isValid())));
if ($this->getResultInstance()->valid() === false) {
// @TODO Move the constant to e.g. BaseDatabaseResult when there is a non-cached database result available
throw new InvalidDatabaseResultException(array($this, $this->getResultInstance()), CachedDatabaseResult::EXCEPTION_INVALID_DATABASE_RESULT);
}
// Get next entry
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-FRAMEWORK-SYSTEM: Invoking this->resultInstance->next() ...');
$this->getResultInstance()->next();
// Fetch it
$entry = $this->getResultInstance()->current();
// And return it
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: entry[]=%s - EXIT!', gettype($entry)));
return $entry;
}
* @param $fieldName Field name which we shall get
* @return $fieldValue Field value from the user
* @throws NullPointerException If the result instance is null
+ * @throws InvalidArgumentException If a parameter is not valid
+ * @deprecated Monolithic method, should be moved to proper classes
*/
public final function getField (string $fieldName) {
+ // Check parameter
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: fieldName=%s - CALLED!', $fieldName));
+ if (empty($fieldName)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "fieldName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
+ // This method is deprecated
+ $this->deprecationWarning('Monolithic method, should be moved to proper classes');
+
// Default field value
$fieldValue = NULL;
$resultInstance = $this->getResultInstance();
// Is this instance null?
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-FRAMEWORK-SYSTEM: resultInstance[]=%s', gettype($resultInstance)));
if (is_null($resultInstance)) {
// Then the user instance is no longer valid (expired cookies?)
- throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
+ throw new NullPointerException($this, FrameworkInterface::EXCEPTION_IS_NULL_POINTER);
}
// Get current array
$fieldArray = $resultInstance->current();
- //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput($fieldName.':<pre>'.print_r($fieldArray, true).'</pre>');
// Convert dashes to underscore
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-FRAMEWORK-SYSTEM: fieldArray()=%d', count($fieldArray)));
$fieldName2 = StringUtils::convertDashesToUnderscores($fieldName);
// Does the field exist?
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-FRAMEWORK-SYSTEM: fieldName2=%s', $fieldName2));
if ($this->isFieldSet($fieldName)) {
// Get it
$fieldValue = $fieldArray[$fieldName2];
- } elseif (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('developer_mode_enabled')) {
+ } elseif (FrameworkBootstrap::getConfigurationInstance()->isEnabled('developer_mode')) {
// Missing field entry, may require debugging
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FRAMEWORK-SYSTEM: fieldArray<pre>=' . print_r($fieldArray, true) . '</pre>,fieldName=' . $fieldName . ' not found!');
+ self::createDebugInstance(__CLASS__, __LINE__)->warningMessage('BASE-FRAMEWORK-SYSTEM: fieldArray<pre>=' . print_r($fieldArray, true) . '</pre>,fieldName=' . $fieldName . ' not found!');
} else {
// Missing field entry, may require debugging
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FRAMEWORK-SYSTEM: fieldName=' . $fieldName . ' not found!');
+ self::createDebugInstance(__CLASS__, __LINE__)->warningMessage('BASE-FRAMEWORK-SYSTEM: fieldName=' . $fieldName . ' not found!');
}
// Return it
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: fieldValue[]=%s - EXIT!', gettype($fieldValue)));
return $fieldValue;
}
* @param $fieldName Field name to check
* @return $isSet Whether the given field name is set
* @throws NullPointerException If the result instance is null
+ * @throws InvalidArgumentException If a parameter is not valid
*/
public function isFieldSet (string $fieldName) {
+ // Check parameter
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: fieldName=%s - CALLED!', $fieldName));
+ if (empty($fieldName)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "fieldName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Get result instance
$resultInstance = $this->getResultInstance();
// Is this instance null?
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-FRAMEWORK-SYSTEM: resultInstance[]=%s', gettype($resultInstance)));
if (is_null($resultInstance)) {
// Then the user instance is no longer valid (expired cookies?)
- throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
+ throw new NullPointerException($this, FrameworkInterface::EXCEPTION_IS_NULL_POINTER);
}
// Get current array
$fieldArray = $resultInstance->current();
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('[' . $this->__toString() . ':' . __LINE__ . '] fieldName=' . $fieldName . ',fieldArray=<pre>'.print_r($fieldArray, true).'</pre>');
// Convert dashes to underscore
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-FRAMEWORK-SYSTEM: fieldArray()=%d,fieldName=%s - BEFORE!', count($fieldArray), $fieldName));
$fieldName = StringUtils::convertDashesToUnderscores($fieldName);
// Determine it
- $isSet = isset($fieldArray[$fieldName]);
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-FRAMEWORK-SYSTEM: fieldName=%s - AFTER!', $fieldName));
+ $isset = isset($fieldArray[$fieldName]);
// Return result
- return $isSet;
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: isset=%d - EXIT!', intval($isset)));
+ return $isset;
}
/**
*
* @param $message The message we shall output to the developer
* @return void
+ * @throws InvalidArgumentException If a paramter has an invalid value
* @todo Write a logging mechanism for productive mode
*/
public function deprecationWarning (string $message) {
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: message=%s - CALLED!', $message));
+ if (empty($message)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "message" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Is developer mode active?
- if (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('developer_mode_enabled')) {
+ if (FrameworkBootstrap::getConfigurationInstance()->isEnabled('developer_mode')) {
// Debug instance is there?
if (!is_null($this->getDebugInstance())) {
// Output stub message
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput($message);
+ self::createDebugInstance(__CLASS__, __LINE__)->warningMessage($message);
} else {
// Trigger an error
trigger_error($message . "<br />\n");
- exit;
+ exit(255);
}
} else {
// @TODO Finish this part!
- $this->partialStub('Developer mode inactive. Message:' . $message);
+ DebugMiddleware::getSelfInstance()->partialStub('Developer mode inactive. Message:' . $message);
}
+
+ // Trace mesage
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-FRAMEWORK-SYSTEM: EXIT!');
}
/**
*
* @param $phpExtension The PHP extension we shall check
* @return $isLoaded Whether the PHP extension is loaded
+ * @throws InvalidArgumentException If a parameter is not valid
*/
public final function isPhpExtensionLoaded (string $phpExtension) {
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: phpExtension=%s - CALLED!', $phpExtension));
+ if (empty($phpExtension)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "phpExtension" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Is it loaded?
$isLoaded = in_array($phpExtension, get_loaded_extensions());
// Return result
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: isLoaded=%d - EXIT!', intval($isLoaded)));
return $isLoaded;
}
*/
public function getMilliTime () {
// Get the time of day as float
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-FRAMEWORK-SYSTEM: CALLED!');
$milliTime = gettimeofday(true);
// Return it
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: milliTime=%s - EXIT!', $milliTime));
return $milliTime;
}
* Idles (sleeps) for given milliseconds
*
* @return $hasSlept Whether it goes fine
+ * @throws InvalidArgumentException If a parameter is not valid
*/
public function idle (int $milliSeconds) {
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: milliSeconds=%s - CALLED!', $milliSeconds));
+ if ($milliSeconds < 1) {
+ // Throw IAE
+ throw new InvalidArgumentException(sprintf('milliSeconds=%d are not a reasonable value to idle', $milliSeconds));
+ }
+
// Sleep is fine by default
$hasSlept = true;
}
// Return result
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: hasSlept=%d - EXIT!', intval($hasSlept)));
return $hasSlept;
}
*
* @param $encodedData Encoded data we shall check
* @return $isBase64 Whether the encoded data is Base64
+ * @throws InvalidArgumentException If a parameter is not valid
*/
protected function isBase64Encoded (string $encodedData) {
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: encodedData=%s - CALLED!', $encodedData));
+ if (empty($encodedData)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "encodedData" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Determine it
$isBase64 = (@base64_decode($encodedData, true) !== false);
// Return it
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: isBase64=%d - EXIT!', intval($isBase64)));
return $isBase64;
}
* @param $key Key to check
* @param $element Element to check
* @return $isset Whether the given key is set
+ * @throws InvalidArgumentException If a parameter is not valid
*/
- protected final function isGenericArrayElementSet (string $keyGroup, string $subGroup, $key, $element) {
+ protected final function isGenericArrayElementSet (string $keyGroup, string $subGroup, string $key, string $element) {
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: keyGroup=%s,subGroup=%s,key=%s,element=%s - CALLED!', $keyGroup, $subGroup, $key, $element));
+ if (empty($keyGroup)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "keyGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($subGroup)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "subGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($key)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "key" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif ($element === '') {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "element" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Is it there?
- //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element);
$isset = isset($this->genericArray[$keyGroup][$subGroup][$key][$element]);
// Return it
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: isset=%d - EXIT!', intval($isset)));
return $isset;
}
/**
* @param $subGroup Sub group for the key
* @param $key Key to check
* @return $isset Whether the given key is set
+ * @throws InvalidArgumentException If a parameter is not valid
*/
- protected final function isGenericArrayKeySet (string $keyGroup, string $subGroup, $key) {
+ protected final function isGenericArrayKeySet (string $keyGroup, string $subGroup, string $key) {
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: keyGroup=%s,subGroup=%s,key=%s - CALLED!', $keyGroup, $subGroup, $key));
+ if (empty($keyGroup)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "keyGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($subGroup)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "subGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($key)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "key" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Is it there?
- //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key);
$isset = isset($this->genericArray[$keyGroup][$subGroup][$key]);
// Return it
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: isset=%d - EXIT!', intval($isset)));
return $isset;
}
-
/**
* Determines if a group is set in the generic array
*
* @param $keyGroup Main group
* @param $subGroup Sub group
* @return $isset Whether the given group is set
+ * @throws InvalidArgumentException If a parameter is not valid
*/
protected final function isGenericArrayGroupSet (string $keyGroup, string $subGroup) {
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: keyGroup=%s,subGroup=%s - CALLED!', $keyGroup, $subGroup));
+ if (empty($keyGroup)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "keyGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($subGroup)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "subGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Is it there?
- //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup);
$isset = isset($this->genericArray[$keyGroup][$subGroup]);
// Return it
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: isset=%d - EXIT!', intval($isset)));
return $isset;
}
* @param $keyGroup Main key group
* @param $subGroup Sub key group
* @return $array An array with all array elements
+ * @throws InvalidArgumentException If a parameter is not valid
+ * @throws BadMethodCallException If key/sub group isn't there but this method is invoked
*/
protected final function getGenericSubArray (string $keyGroup, string $subGroup) {
- // Is it there?
- if (!$this->isGenericArrayGroupSet($keyGroup, $subGroup)) {
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: keyGroup=%s,subGroup=%s - CALLED!', $keyGroup, $subGroup));
+ if (empty($keyGroup)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "keyGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($subGroup)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "subGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (!$this->isGenericArrayGroupSet($keyGroup, $subGroup)) {
// No, then abort here
- trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ' not found.');
- exit;
+ throw new BadMethodCallException(sprintf('keyGroup=%s,subGroup=%s not found.', $keyGroup, $subGroup), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
}
// Return it
- //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',value=' . print_r($this->genericArray[$keyGroup][$subGroup], true));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: this->genericArray[%s][%s][]=%s - EXIT!', $keyGroup, $subGroup, gettype($this->genericArray[$keyGroup][$subGroup])));
return $this->genericArray[$keyGroup][$subGroup];
}
* @param $subGroup Sub group for the key
* @param $key Key to unset
* @return void
+ * @throws InvalidArgumentException If a parameter is not valid
*/
- protected final function unsetGenericArrayKey (string $keyGroup, string $subGroup, $key) {
+ protected final function unsetGenericArrayKey (string $keyGroup, string $subGroup, string $key) {
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: keyGroup=%s,subGroup=%s,key=%s - CALLED!', $keyGroup, $subGroup, $key));
+ if (empty($keyGroup)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "keyGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($subGroup)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "subGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($key)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "key" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Remove it
- //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key);
unset($this->genericArray[$keyGroup][$subGroup][$key]);
+
+ // Trace mesage
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-FRAMEWORK-SYSTEM: EXIT!');
}
/**
* @param $key Key to unset
* @param $element Element to unset
* @return void
+ * @throws InvalidArgumentException If a parameter is not valid
*/
- protected final function unsetGenericArrayElement (string $keyGroup, string $subGroup, $key, $element) {
- // Debug message
- //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element);
+ protected final function unsetGenericArrayElement (string $keyGroup, string $subGroup, string $key, string $element) {
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: keyGroup=%s,subGroup=%s,key=%s,element=%s - CALLED!', $keyGroup, $subGroup, $key, $element));
+ if (empty($keyGroup)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "keyGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($subGroup)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "subGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($key)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "key" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif ($element === '') {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "element" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
// Remove it
unset($this->genericArray[$keyGroup][$subGroup][$key][$element]);
+
+ // Trace mesage
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-FRAMEWORK-SYSTEM: EXIT!');
}
/**
* @param $key Key to unset
* @param $value Value to add/append
* @return void
+ * @throws InvalidArgumentException If a parameter is not valid
*/
- protected final function appendStringToGenericArrayKey (string $keyGroup, string $subGroup, $key, string $value, $appendGlue = '') {
- // Debug message
- //* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',value[' . gettype($value) . ']=' . print_r($value, true) . ',appendGlue=' . $appendGlue);
+ protected final function appendStringToGenericArrayKey (string $keyGroup, string $subGroup, string $key, string $value, string $appendGlue = '') {
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: keyGroup=%s,subGroup=%s,key=%s,value=%s,appendGlue=%s - CALLED!', $keyGroup, $subGroup, $key, $value, $appendGlue));
+ if (empty($keyGroup)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "keyGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($subGroup)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "subGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($key)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "key" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
// Is it already there?
if ($this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) {
// Append it
- $this->genericArray[$keyGroup][$subGroup][$key] .= $appendGlue . (string) $value;
+ $this->genericArray[$keyGroup][$subGroup][$key] .= $appendGlue . $value;
} else {
// Add it
- $this->genericArray[$keyGroup][$subGroup][$key] = (string) $value;
+ $this->genericArray[$keyGroup][$subGroup][$key] = $value;
}
+
+ // Trace mesage
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-FRAMEWORK-SYSTEM: EXIT!');
}
/**
* @param $element Element to check
* @param $value Value to add/append
* @return void
+ * @throws InvalidArgumentException If a parameter is not valid
*/
- protected final function appendStringToGenericArrayElement (string $keyGroup, string $subGroup, $key, $element, $value, $appendGlue = '') {
- // Debug message
- //* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ',value[' . gettype($value) . ']=' . print_r($value, true) . ',appendGlue=' . $appendGlue);
+ protected final function appendStringToGenericArrayElement (string $keyGroup, string $subGroup, string $key, string $element, string $value, string $appendGlue = '') {
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: keyGroup=%s,subGroup=%s,key=%s,element=%s,value=%s,appendGlue=%s - CALLED!', $keyGroup, $subGroup, $key, $element, $value, $appendGlue));
+ if (empty($keyGroup)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "keyGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($subGroup)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "subGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($key)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "key" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif ($element === '') {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "element" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
// Is it already there?
if ($this->isGenericArrayElementSet($keyGroup, $subGroup, $key, $element)) {
// Append it
- $this->genericArray[$keyGroup][$subGroup][$key][$element] .= $appendGlue . (string) $value;
+ $this->genericArray[$keyGroup][$subGroup][$key][$element] .= $appendGlue . $value;
} else {
// Add it
- $this->setStringGenericArrayElement($keyGroup, $subGroup, $key, $element, $value);
+ $this->setGenericArrayElement($keyGroup, $subGroup, $key, $element, $value);
}
- }
-
- /**
- * Sets a string in a given generic array element
- *
- * @param $keyGroup Main group for the key
- * @param $subGroup Sub group for the key
- * @param $key Key to unset
- * @param $element Element to check
- * @param $value Value to add/append
- * @return void
- */
- protected final function setStringGenericArrayElement (string $keyGroup, string $subGroup, $key, $element, $value, $appendGlue = '') {
- // Debug message
- //* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ',value[' . gettype($value) . ']=' . print_r($value, true) . ',appendGlue=' . $appendGlue);
- // Set it
- $this->genericArray[$keyGroup][$subGroup][$key][$element] = (string) $value;
+ // Trace mesage
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-FRAMEWORK-SYSTEM: EXIT!');
}
/**
* @param $key Key to use
* @param $forceInit Optionally force initialization
* @return void
+ * @throws InvalidArgumentException If a parameter is not valid
+ * @throws BadMethodCallException If key/sub group has already been initialized
*/
protected final function initGenericArrayGroup (string $keyGroup, string $subGroup, bool $forceInit = false) {
- // Debug message
- //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',forceInit=' . intval($forceInit));
-
- // Is it already set?
- if (($forceInit === false) && ($this->isGenericArrayGroupSet($keyGroup, $subGroup))) {
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: keyGroup=%s,subGroup=%s,forceInit=%d - CALLED!', $keyGroup, $subGroup, intval($forceInit)));
+ if (empty($keyGroup)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "keyGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($subGroup)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "subGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (($forceInit === false) && ($this->isGenericArrayGroupSet($keyGroup, $subGroup))) {
// Already initialized
- trigger_error(__METHOD__ . ':keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ' already initialized.');
- exit;
+ throw new BadMethodCallException(sprintf('keyGroup=%s,subGroup=%s already initialized.', $keyGroup, $subGroup), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
}
// Initialize it
$this->genericArray[$keyGroup][$subGroup] = [];
+
+ // Trace mesage
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-FRAMEWORK-SYSTEM: EXIT!');
}
/**
* @param $key Key to use
* @param $forceInit Optionally force initialization
* @return void
+ * @throws InvalidArgumentException If a parameter is not valid
+ * @throws BadMethodCallException If key/sub group has already been initialized
*/
- protected final function initGenericArrayKey (string $keyGroup, string $subGroup, $key, bool $forceInit = false) {
- // Debug message
- //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',forceInit=' . intval($forceInit));
-
- // Is it already set?
- if (($forceInit === false) && ($this->isGenericArrayKeySet($keyGroup, $subGroup, $key))) {
+ protected final function initGenericArrayKey (string $keyGroup, string $subGroup, string $key, bool $forceInit = false) {
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: keyGroup=%s,subGroup=%s,key=%s,forceInit=%d - CALLED!', $keyGroup, $subGroup, $key, intval($forceInit)));
+ if (empty($keyGroup)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "keyGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($subGroup)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "subGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($key)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "key" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (($forceInit === false) && ($this->isGenericArrayKeySet($keyGroup, $subGroup, $key))) {
// Already initialized
- trigger_error(__METHOD__ . ':keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ' already initialized.');
- exit;
+ throw new BadMethodCallException(sprintf('keyGroup=%s,subGroup=%s,key[%s]=%s already initialized.', $keyGroup, $subGroup, gettype($key), $key), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
}
// Initialize it
$this->genericArray[$keyGroup][$subGroup][$key] = [];
+
+ // Trace mesage
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-FRAMEWORK-SYSTEM: EXIT!');
}
/**
* @param $element Element to use
* @param $forceInit Optionally force initialization
* @return void
+ * @throws InvalidArgumentException If a parameter is not valid
+ * @throws BadMethodCallException If key/sub group isn't there but this method is invoked
*/
- protected final function initGenericArrayElement (string $keyGroup, string $subGroup, $key, $element, bool $forceInit = false) {
- // Debug message
- //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ',forceInit=' . intval($forceInit));
-
- // Is it already set?
- if (($forceInit === false) && ($this->isGenericArrayElementSet($keyGroup, $subGroup, $key, $element))) {
+ protected final function initGenericArrayElement (string $keyGroup, string $subGroup, string $key, string $element, bool $forceInit = false) {
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: keyGroup=%s,subGroup=%s,key=%s,element=%s,forceInit=%d - CALLED!', $keyGroup, $subGroup, $key, $element, intval($forceInit)));
+ if (empty($keyGroup)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "keyGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($subGroup)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "subGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($key)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "key" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif ($element === '') {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "element" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (($forceInit === false) && ($this->isGenericArrayElementSet($keyGroup, $subGroup, $key, $element))) {
// Already initialized
- trigger_error(__METHOD__ . ':keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ' already initialized.');
- exit;
+ throw new BadMethodCallException(sprintf('keyGroup=%s,subGroup=%s,key[%s]=%s,element[%s]=%s already initialized.', $keyGroup, $subGroup, gettype($key), $key, gettype($element), $element), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
}
// Initialize it
$this->genericArray[$keyGroup][$subGroup][$key][$element] = [];
+
+ // Trace mesage
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-FRAMEWORK-SYSTEM: EXIT!');
}
/**
- * Pushes an element to a generic key
+ * Pushes an element to a generic key. If the key isn't found, it will be initialized.
*
* @param $keyGroup Main group for the key
* @param $subGroup Sub group for the key
* @param $key Key to use
* @param $value Value to add/append
* @return $count Number of array elements
+ * @throws InvalidArgumentException If a parameter is not valid
*/
- protected final function pushValueToGenericArrayKey (string $keyGroup, string $subGroup, $key, $value) {
- // Debug message
- //* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',value[' . gettype($value) . ']=' . print_r($value, true));
-
- // Is it set?
- if (!$this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) {
+ protected final function pushValueToGenericArrayKey (string $keyGroup, string $subGroup, string $key, $value) {
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: keyGroup=%s,subGroup=%s,key=%s,value[]=%s - CALLED!', $keyGroup, $subGroup, $key, gettype($value)));
+ if (empty($keyGroup)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "keyGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($subGroup)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "subGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($key)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "key" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (!$this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) {
// Initialize array
$this->initGenericArrayKey($keyGroup, $subGroup, $key);
}
// Return count
//* DEBUG: */ print(__METHOD__ . ': genericArray=' . print_r($this->genericArray[$keyGroup][$subGroup][$key], true));
- //* DEBUG: */ print(__METHOD__ . ': count=' . $count . PHP_EOL);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: count=%d - EXIT!', $count));
return $count;
}
/**
- * Pushes an element to a generic array element
+ * Pushes an element to a generic array element. If the key isn't found, it will be initialized.
*
* @param $keyGroup Main group for the key
* @param $subGroup Sub group for the key
* @param $element Element to check
* @param $value Value to add/append
* @return $count Number of array elements
+ * @throws InvalidArgumentException If a parameter is not valid
*/
- protected final function pushValueToGenericArrayElement (string $keyGroup, string $subGroup, $key, $element, $value) {
- // Debug message
- //* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ',value[' . gettype($value) . ']=' . print_r($value, true));
-
- // Is it set?
- if (!$this->isGenericArrayElementSet($keyGroup, $subGroup, $key, $element)) {
+ protected final function pushValueToGenericArrayElement (string $keyGroup, string $subGroup, string $key, string $element, $value) {
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: keyGroup=%s,subGroup=%s,key=%s,element=%s,value[]=%s - CALLED!', $keyGroup, $subGroup, $key, $element, gettype($value)));
+ if (empty($keyGroup)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "keyGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($subGroup)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "subGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($key)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "key" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif ($element === '') {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "element" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (!$this->isGenericArrayElementSet($keyGroup, $subGroup, $key, $element)) {
// Initialize array
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: Invoking this->initGenericArrayElement(%s,%s,%s,%s) ...', $keyGroup, $subGroup, $key, $element));
$this->initGenericArrayElement($keyGroup, $subGroup, $key, $element);
}
// Return count
//* DEBUG: */ print(__METHOD__ . ': genericArray=' . print_r($this->genericArray[$keyGroup][$subGroup][$key], true));
- //* DEBUG: */ print(__METHOD__ . ': count=' . $count . PHP_EOL);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: count=%d - EXIT!', $count));
return $count;
}
* @param $subGroup Sub group for the key
* @param $key Key to unset
* @return $value Last "popped" value
+ * @throws InvalidArgumentException If a parameter is not valid
+ * @throws BadMethodCallException If key/sub group isn't there but this method is invoked
*/
- protected final function popGenericArrayElement (string $keyGroup, string $subGroup, $key) {
- // Debug message
- //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key);
-
- // Is it set?
- if (!$this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) {
+ protected final function popGenericArrayElement (string $keyGroup, string $subGroup, string $key) {
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: keyGroup=%s,subGroup=%s,key=%s - CALLED!', $keyGroup, $subGroup, $key));
+ if (empty($keyGroup)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "keyGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($subGroup)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "subGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($key)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "key" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (!$this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) {
// Not found
- trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ' not found.');
- exit;
+ throw new BadMethodCallException(sprintf('keyGroup=%s,subGroup=%s,key[%s]=%s not found.', $keyGroup, $subGroup, gettype($key), $key), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
}
// Then "pop" it
// Return value
//* DEBUG: */ print(__METHOD__ . ': genericArray=' . print_r($this->genericArray[$keyGroup][$subGroup][$key], true));
- //* DEBUG: */ print(__METHOD__ . ': value[' . gettype($value) . ']=' . print_r($value, true) . PHP_EOL);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: value[]=%s - EXIT!', gettype($value)));
return $value;
}
* @param $keyGroup Main group for the key
* @param $subGroup Sub group for the key
* @param $key Key to unset
- * @return $value Last "popped" value
- */
- protected final function shiftGenericArrayElement (string $keyGroup, string $subGroup, $key) {
- // Debug message
- //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key);
-
- // Is it set?
- if (!$this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) {
+ * @return $value Last "shifted" value
+ * @throws InvalidArgumentException If a parameter is not valid
+ * @throws BadMethodCallException If key/sub group isn't there but this method is invoked
+ */
+ protected final function shiftGenericArrayElement (string $keyGroup, string $subGroup, string $key) {
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: keyGroup=%s,subGroup=%s,key=%s - CALLED!', $keyGroup, $subGroup, $key));
+ if (empty($keyGroup)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "keyGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($subGroup)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "subGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($key)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "key" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (!$this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) {
// Not found
- trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ' not found.');
- exit;
+ throw new BadMethodCallException(sprintf('keyGroup=%s,subGroup=%s,key[%s]=%s not found.', $keyGroup, $subGroup, gettype($key), $key), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
}
// Then "shift" it
// Return value
//* DEBUG: */ print(__METHOD__ . ': genericArray=' . print_r($this->genericArray[$keyGroup][$subGroup][$key], true));
- //* DEBUG: */ print(__METHOD__ . ': value[' . gettype($value) . ']=' . print_r($value, true) . PHP_EOL);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: value[]=%s - EXIT!', gettype($value)));
return $value;
}
*
* @param $keyGroup Main group for the key
* @return $count Count of given group
+ * @throws InvalidArgumentException If a parameter is not valid
+ * @throws BadMethodCallException If key group isn't there but this method is invoked
*/
protected final function countGenericArray (string $keyGroup) {
- // Debug message
- //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup);
-
- // Is it there?
- if (!isset($this->genericArray[$keyGroup])) {
- // Abort here
- trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ' not found.');
- exit;
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: keyGroup=%s - CALLED!', $keyGroup));
+ if (empty($keyGroup)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "keyGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (!isset($this->genericArray[$keyGroup])) {
+ // Not found
+ throw new BadMethodCallException(sprintf('keyGroup=%s not found.', $keyGroup), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
}
// Then count it
$count = count($this->genericArray[$keyGroup]);
- // Debug message
- //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',count=' . $count);
-
// Return it
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: count=%d - EXIT!', $count));
return $count;
}
* @param $keyGroup Main group for the key
* @param $subGroup Sub group for the key
* @return $count Count of given group
+ * @throws InvalidArgumentException If a parameter is not valid
+ * @throws BadMethodCallException If key/sub group isn't there but this method is invoked
*/
protected final function countGenericArrayGroup (string $keyGroup, string $subGroup) {
- // Debug message
- //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup);
-
- // Is it there?
- if (!$this->isGenericArrayGroupSet($keyGroup, $subGroup)) {
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: keyGroup=%s,subGroup=%s - CALLED!', $keyGroup, $subGroup));
+ if (empty($keyGroup)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "keyGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($subGroup)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "subGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (!$this->isGenericArrayGroupSet($keyGroup, $subGroup)) {
// Abort here
- trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ' not found.');
- exit;
+ throw new BadMethodCallException(sprintf('keyGroup=%s,subGroup=%s not found.', $keyGroup, $subGroup), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
}
// Then count it
$count = count($this->genericArray[$keyGroup][$subGroup]);
- // Debug message
- //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',count=' . $count);
-
// Return it
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: count=%d - EXIT!', $count));
return $count;
}
*
* @param $keyGroup Main group for the key
* @param $subGroup Sub group for the key
- * @para $key Key to count
+ * @param $key Key to count
* @return $count Count of given key
+ * @throws InvalidArgumentException If a parameter is not valid
+ * @throws BadMethodCallException If key/sub group isn't there but this method is invoked
*/
- protected final function countGenericArrayElements (string $keyGroup, string $subGroup, $key) {
- // Debug message
- //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key);
-
- // Is it there?
- if (!$this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) {
+ protected final function countGenericArrayElements (string $keyGroup, string $subGroup, string $key) {
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: keyGroup=%s,subGroup=%s,key=%s - CALLED!', $keyGroup, $subGroup, $key));
+ if (empty($keyGroup)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "keyGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($subGroup)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "subGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($key)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "key" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (!$this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) {
// Abort here
- trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ' not found.');
- exit;
+ throw new BadMethodCallException(sprintf('keyGroup=%s,subGroup=%s,key[%s]=%s not found.', $keyGroup, $subGroup, gettype($key), $key), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
} elseif (!$this->isValidGenericArrayGroup($keyGroup, $subGroup)) {
// Not valid
- trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ' is not an array.');
- exit;
+ throw new BadMethodCallException(sprintf('keyGroup=%s,subGroup=%s is not a valid key/sub group.', $keyGroup, $subGroup), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
}
// Then count it
$count = count($this->genericArray[$keyGroup][$subGroup][$key]);
- // Debug message
- //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',count=' . $count);
-
// Return it
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: count=%d - EXIT!', $count));
return $count;
}
*
* @param $keyGroup Key group to get
* @return $array Whole generic array group
+ * @throws InvalidArgumentException If a parameter is not valid
+ * @throws BadMethodCallException If key/sub group isn't there but this method is invoked
*/
protected final function getGenericArray (string $keyGroup) {
- // Debug message
- //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup);
-
- // Is it there?
- if (!isset($this->genericArray[$keyGroup])) {
+ // Check parameters
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: keyGroup=%s - CALLED!', $keyGroup));
+ if (empty($keyGroup)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "keyGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (!isset($this->genericArray[$keyGroup])) {
// Then abort here
- trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ' does not exist.');
- exit;
+ throw new BadMethodCallException(sprintf('keyGroup=%s not found', $keyGroup), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
}
// Return it
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: this->genericArray[%s][]=%s - EXIT!', $keyGroup, gettype($this->genericArray[$keyGroup])));
return $this->genericArray[$keyGroup];
}
* @param $key Key to unset
* @param $value Mixed value from generic array element
* @return void
+ * @throws InvalidArgumentException If a parameter is not valid
+ * @throws BadMethodCallException If key/sub group isn't there but this method is invoked
*/
- protected final function setGenericArrayKey (string $keyGroup, string $subGroup, $key, $value) {
- // Debug message
- //* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',value[' . gettype($value) . ']=' . print_r($value, true));
+ protected final function setGenericArrayKey (string $keyGroup, string $subGroup, string $key, $value) {
+ // Check parameters
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: keyGroup=%s,subGroup=%s,key=%s,value[]=%s - CALLED!', $keyGroup, $subGroup, $key, gettype($value)));
+ if (empty($keyGroup)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "keyGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($subGroup)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "subGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($key)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "key" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (!$this->isValidGenericArrayGroup($keyGroup, $subGroup)) {
+ // Then abort here
+ throw new BadMethodCallException(sprintf('keyGroup=%s,subGroup=%s not found', $keyGroup), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
+ }
// Set value here
$this->genericArray[$keyGroup][$subGroup][$key] = $value;
+
+ // Trace mesage
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-FRAMEWORK-SYSTEM: EXIT!');
}
/**
* @param $subGroup Sub group for the key
* @param $key Key to unset
* @return $value Mixed value from generic array element
+ * @throws InvalidArgumentException If a parameter is not valid
+ * @throws BadMethodCallException If key/sub group isn't there but this method is invoked
*/
- protected final function getGenericArrayKey (string $keyGroup, string $subGroup, $key) {
- // Debug message
- //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key);
-
- // Is it there?
- if (!$this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) {
+ protected final function getGenericArrayKey (string $keyGroup, string $subGroup, string $key) {
+ // Check parameters
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: keyGroup=%s,subGroup=%s,key=%s - CALLED!', $keyGroup, $subGroup, $key));
+ if (empty($keyGroup)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "keyGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($subGroup)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "subGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($key)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "key" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (!$this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) {
// Then abort here
- trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ' does not exist.');
- exit;
+ throw new BadMethodCallException(sprintf('keyGroup=%s,subGroup=%s,key[%s]=%s not found.', $keyGroup, $subGroup, gettype($key), $key), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
}
// Return it
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: this->genericArray[%s][%s][%s][]=%s - EXIT!', $keyGroup, $subGroup, $key, gettype($this->genericArray[$keyGroup][$subGroup][$key])));
return $this->genericArray[$keyGroup][$subGroup][$key];
}
* @param $element Element to set
* @param $value Value to set
* @return void
+ * @throws InvalidArgumentException If a parameter is not valid
*/
- protected final function setGenericArrayElement (string $keyGroup, string $subGroup, $key, $element, $value) {
- // Debug message
- //* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ',value[' . gettype($value) . ']=' . print_r($value, true));
+ protected final function setGenericArrayElement (string $keyGroup, string $subGroup, string $key, string $element, $value) {
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: keyGroup=%s,subGroup=%s,key=%s,element=%s,value[]=%s - CALLED!', $keyGroup, $subGroup, $key, $element, gettype($value)));
+ if (empty($keyGroup)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "keyGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($subGroup)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "subGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($key)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "key" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif ($element === '') {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "element" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (!$this->isGenericArrayElementSet($keyGroup, $subGroup, $key, $element)) {
+ // Initialize array
+ $this->initGenericArrayElement($keyGroup, $subGroup, $key, $element);
+ }
// Then set it
$this->genericArray[$keyGroup][$subGroup][$key][$element] = $value;
+
+ // Trace mesage
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-FRAMEWORK-SYSTEM: EXIT!');
}
/**
* @param $key Key to look for
* @param $element Element to look for
* @return $value Mixed value from generic array element
+ * @throws InvalidArgumentException If a parameter is not valid
+ * @throws BadMethodCallException If key/sub group isn't there but this method is invoked
*/
- protected final function getGenericArrayElement (string $keyGroup, string $subGroup, $key, $element) {
- // Debug message
- //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element);
-
- // Is it there?
- if (!$this->isGenericArrayElementSet($keyGroup, $subGroup, $key, $element)) {
+ protected final function getGenericArrayElement (string $keyGroup, string $subGroup, string $key, string $element) {
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: keyGroup=%s,subGroup=%s,key=%s,element=%s - CALLED!', $keyGroup, $subGroup, $key, $element));
+ if (empty($keyGroup)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "keyGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($subGroup)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "subGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($key)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "key" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif ($element === '') {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "element" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (!$this->isGenericArrayElementSet($keyGroup, $subGroup, $key, $element)) {
// Then abort here
- trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ' does not exist.');
- exit;
+ throw new BadMethodCallException(sprintf('keyGroup=%s,subGroup=%s,key[%s]=%s,element[%s]=%s not found.', $keyGroup, $subGroup, gettype($key), $key, gettype($element), $element), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
}
// Return it
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: this->genericArray[%s][%s][%s][%s][]=%s - EXIT!', $keyGroup, $subGroup, $key, gettype($this->genericArray[$keyGroup][$subGroup][$key][$element])));
return $this->genericArray[$keyGroup][$subGroup][$key][$element];
}
* @param $keyGroup Key group to get
* @param $subGroup Sub group for the key
* @return $isValid Whether given sub group is valid
+ * @throws InvalidArgumentException If a parameter is not valid
*/
protected final function isValidGenericArrayGroup (string $keyGroup, string $subGroup) {
- // Debug message
- //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup);
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: keyGroup=%s,subGroup=%s - CALLED!', $keyGroup, $subGroup));
+ if (empty($keyGroup)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "keyGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($subGroup)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "subGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
// Determine it
$isValid = (($this->isGenericArrayGroupSet($keyGroup, $subGroup)) && (is_array($this->getGenericSubArray($keyGroup, $subGroup))));
// Return it
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: isValid=%d - EXIT!', intval($isValid)));
return $isValid;
}
* @param $key Key to check
* @return $isValid Whether given sub group is valid
*/
- protected final function isValidGenericArrayKey (string $keyGroup, string $subGroup, $key) {
- // Debug message
- //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key);
+ protected final function isValidGenericArrayKey (string $keyGroup, string $subGroup, string $key) {
+ // Check parameters
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: keyGroup=%s,subGroup=%s,key=%s - CALLED!', $keyGroup, $subGroup, $key));
+ if (empty($keyGroup)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "keyGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($subGroup)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "subGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($key)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "key" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
// Determine it
$isValid = (($this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) && (is_array($this->getGenericArrayKey($keyGroup, $subGroup, $key))));
// Return it
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: isValid=%d - EXIT!', intval($isValid)));
return $isValid;
}
*/
protected function initWebOutputInstance () {
// Init web output instance
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-FRAMEWORK-SYSTEM: CALLED!');
$outputInstance = ObjectFactory::createObjectByConfiguredName('output_class');
// Set it locally
$this->setWebOutputInstance($outputInstance);
+
+ // Trace mesage
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-FRAMEWORK-SYSTEM: EXIT!');
}
/**
*/
public static final function translateBooleanToYesNo (bool $boolean) {
// "Translate" it
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: boolean=%d - CALLED!', intval($boolean)));
$translated = ($boolean === true) ? 'Y' : 'N';
// ... and return it
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: translated=%s - EXIT!', $translated));
return $translated;
}
* a configured temporary file path to it.
*
* @param $infoInstance An instance of a SplFileInfo class
- * @return $tempInstance An instance of a SplFileInfo class (temporary file)
+ * @return $fileInfoInstance An instance of a SplFileInfo class (temporary file)
* @throw PathWriteProtectedException If the path in 'temp_file_path' is write-protected
* @throws FileIoException If the file cannot be written
*/
protected static function createTempPathForFile (SplFileInfo $infoInstance) {
// Get config entry
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: infoInstance=%s - CALLED!', $infoInstance->__toString()));
$basePath = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('temp_file_path');
// Is the path writeable?
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: basePath=%s', $basePath));
if (!is_writable($basePath)) {
// Path is write-protected
throw new PathWriteProtectedException($infoInstance, self::EXCEPTION_PATH_CANNOT_BE_WRITTEN);
}
// Add it
- $tempInstance = new SplFileInfo($basePath . DIRECTORY_SEPARATOR . $infoInstance->getBasename());
+ $fileInfoInstance = new SplFileInfo($basePath . DIRECTORY_SEPARATOR . $infoInstance->getBasename());
// Is it reachable?
- if (!FrameworkBootstrap::isReachableFilePath($tempInstance)) {
+ if (!FrameworkBootstrap::isReachableFilePath($fileInfoInstance)) {
// Not reachable
- throw new FileIoException($tempInstance, self::EXCEPTION_FILE_NOT_REACHABLE);
+ throw new FileIoException($fileInfoInstance, self::EXCEPTION_FILE_NOT_REACHABLE);
}
// Return it
- return $tempInstance;
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: fileInfoInstance=%s - EXIT!', $fileInfoInstance->__toString()));
+ return $fileInfoInstance;
}
/**
* "Getter" for a printable state name
*
* @return $stateName Name of the node's state in a printable format
+ * @throws BadMethodCallException If this instance doesn't have a callable getter for stateInstance
* @todo Move this class away from this monolithic place (not whole class is monolithic)
*/
public final function getPrintableState () {
+ // Check if getter is there
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-FRAMEWORK-SYSTEM: CALLED!');
+ if (!is_callable($this, 'getStateInstance')) {
+ // Throw BMCE
+ throw new BadMethodCallException(sprintf('this=%s has no callable getter for stateInstance', $this->__toString()), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
+ }
+
// Default is 'null'
$stateName = 'null';
$stateInstance = $this->getStateInstance();
// Is it an instance of Stateable?
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: stateInstance[]=%s', gettype($stateInstance)));
if ($stateInstance instanceof Stateable) {
// Then use that state name
$stateName = $stateInstance->getStateName();
}
// Return result
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: stateName=%s - EXIT!', $stateName));
return $stateName;
}
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
use Org\Mxchange\CoreFramework\Client\BaseClient;
use Org\Mxchange\CoreFramework\Client\Client;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
+
+// Import SPL stuff
+use \InvalidArgumentException;
+use \UnexpectedValueException;
/**
* A HTTP client class
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
*/
public final static function createHttpClient ($socketResouce = FALSE) {
// Get a new instance
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HTTP-CLIENT: socketResource[%s]=%s - CALLED!', gettype($socketResource), $socketResource));
$clientInstance = new HttpClient();
// Set socket resource
$clientInstance->setSocketResource($socketResource);
// Return the prepared instance
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HTTP-CLIENT: clientInstance=%s - EXIT!', $clientInstance->__toString()));
return $clientInstance;
}
*/
protected function isProxyUsed () {
// Do we have cache?
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HTTP-CLIENT: CALLED!');
if (!isset($GLOBALS[__METHOD__])) {
// Determine it
$GLOBALS[__METHOD__] = ((FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('proxy_host') != '') && (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('proxy_port') > 0));
}
// Return cache
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HTTP-CLIENT: isProxyUsed=%d - EXIT!', $GLOBALS[__METHOD__]));
return $GLOBALS[__METHOD__];
}
* @param $host Host to connect to
* @param $port Port number to connect to
* @return $response Response array
+ * @throws InvalidArgumentException If a paramter has an invalid value
+ * @throws UnexpectedValueException If an unexpected value was found
*/
protected function setupProxyTunnel (string $host, int $port) {
+ // Check paramters
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HTTP-CLIENT: host=%s,port=%d - CALLED!', $host, $port));
+ if (empty($host)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "host" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif ($port < 1) {
+ // Throw IAE
+ throw new InvalidArgumentException(sprintf('port=%d is not a valid port number', $port), FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Initialize array
$response = ['', '', ''];
// Do the connect
- $respArray = $this->doConnectRequest($host, $port);
+ $responseArray = $this->doConnectRequest($host, $port);
+
+ // Check array
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HTTP-CLIENT: responseArray()=%d', count($responseArray)));
+ if (count($responseArray) < 2) {
+ // Not expected count
+ throw new UnexpectedValueException(sprintf('responseArray()=%d must have at least two elements', count($responseArray)), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
+ }
// Analyze first header line
- if (((strtolower($respArray[0]) !== 'http/1.0') && (strtolower($respArray[0]) !== 'http/1.1')) || ($respArray[1] != '200')) {
+ if (((strtolower($responseArray[0]) !== 'http/1.0') && (strtolower($responseArray[0]) !== 'http/1.1')) || ($responseArray[1] != '200')) {
// Response code is not 200
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HTTP-CLIENT: Returning empty response array - EXIT!');
return $response;
}
// All fine!
- return $respArray;
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HTTP-CLIENT: responseArray()=%d - EXIT!', count($responseArray)));
+ return $responseArray;
}
/**
*/
private function sendRawHttpRequest (string $method, string $host, int $port, array $header = []) {
// Minimum raw HTTP/1.1 request
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HTTP-CLIENT: method=%s,host=%s,port=%d,header()=%d - CALLED!', $method, $host, $port, count($header)));
$rawRequest = $method . ' ' . $host . ':' . $port . ' HTTP/1.1' . self::HTTP_EOL;
$rawRequest .= 'Host: ' . $host . ':' . $port . self::HTTP_EOL;
//* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HTTP-CLIENT: rawRequest=' . $rawRequest);
// Write request
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HTTP-CLIENT: Sending %d bytes to this->socketResource=%s ...', strlen($rawRequest), $this->getSocketResource()));
fwrite($this->getSocketResource(), $rawRequest);
// Got response?
- if (feof($this->getSocketResource())) {
+ $feof = feof($this->getSocketResource());
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HTTP-CLIENT: this->socketResource=%s,feof=%d', $this->getSocketResource(), intval($feof)));
+ if ($feof) {
// No response received
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HTTP-CLIENT: this->socketResource=%s has reached EOF - EXIT!', $this->getSocketResource()));
return $response;
}
// Read the first line
- $resp = trim(fgets($this->getSocketResource(), 10240));
+ $rawResponse = trim(fgets($this->getSocketResource(), 10240));
// "Explode" the string to an array
- $responseArray = explode(' ', $resp);
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HTTP-CLIENT: Received %d bytes back from this->socketResource=%s ...', strlen($rawResponse), $this->getSocketResource()));
+ $responseArray = explode(' ', $rawResponse);
// And return it
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HTTP-CLIENT: responseArray()=%d - EXIT!', count($responseArray)));
return $responseArray;
}
* @param $host Host to connect to
* @param $port Port number to connect to
* @return $responseArray An array with the read response
+ * @throws InvalidArgumentException If a paramter has an invalid value
*/
public function doConnectRequest (string $host, int $port) {
+ // Check paramters
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HTTP-CLIENT: host=%s,port=%d - CALLED!', $host, $port));
+ if (empty($host)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "host" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif ($port < 1) {
+ // Throw IAE
+ throw new InvalidArgumentException(sprintf('port=%d is not a valid port number', $port), FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Prepare extra header(s)
$headers = [
'Proxy-Connection' => 'Keep-Alive'
];
// Prepare raw request
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HTTP-CLIENT: Invoking this->sendRawHttpRequest(CONNECT,%s,%d,headers()=%d) ...', $host, $port, count($headers)));
$responseArray = $this->sendRawHttpRequest('CONNECT', $host, $port, $headers);
// Return response array
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HTTP-CLIENT: responseArray()=%d - EXIT!', count($responseArray)));
return $responseArray;
}
<?php
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
+
/**
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
* @return void
*/
public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- $this->partialStub('Unfinished!');
+ DebugMiddleware::getSelfInstance()->partialStub('Unfinished!');
}
/**
* @return void
*/
public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
- $this->partialStub('Unfinished!');
+ DebugMiddleware::getSelfInstance()->partialStub('Unfinished!');
}
}
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
use Org\Mxchange\CoreFramework\Request\Requestable;
use Org\Mxchange\CoreFramework\Response\Responseable;
use Org\Mxchange\CoreFramework\Traits\Resolver\ResolverTrait;
use Org\Mxchange\CoreFramework\Traits\Template\CompileableTemplateTrait;
+// Import SPL stuff
+use \BadMethodCallException;
+use \InvalidArgumentException;
+
/**
* A general (base) command
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @param $templateType Type of template, e.g. 'html', 'image', 'console' ...
* @return void
+ * @throws InvalidArgumentException If a parameter has an invalid value
*/
public final function initTemplateEngine (string $templateType) {
+ // Check paramter
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-COMMAND: templateType=%s - CALLED!', $templateType));
+ if (empty($templateType)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "templateType" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Prepare a template instance
$templateInstance = ObjectFactory::createObjectByConfiguredName(sprintf('%s_template_class', $templateType));
// Set it here
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-COMMAND: templateInstance=%s', $templateInstance->__toString()));
$this->setTemplateInstance($templateInstance);
+
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-COMMAND: EXIT!');
}
/**
* @param $responseInstance An instance of a class with an Responseable interface
* @param $suffix Optional template suffix, e.g. '_form' for forms
* @return void
+ * @throws BadMethodCallException If a POST request ended here
*/
protected function sendGenericGetResponse (Requestable $requestInstance, Responseable $responseInstance, string $suffix = '') {
- // This command doesn't handle any POST requests, so only handle get request
- assert(!$requestInstance->isPostRequestMethod());
-
- // Get the application instance
- $applicationInstance = ApplicationHelper::getSelfInstance();
+ // Check conditions
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-COMMAND: requestInstance=%s,responseInstance=%s,suffix=%s - CALLED!', $requestInstance->__toString(), $responseInstance->__toString(), $suffix));
+ if ($requestInstance->isPostRequestMethod()) {
+ // POST request isn't handled here
+ throw new BadMethodCallException('This method does only handle GET/HEAD requests', FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
+ }
// Transfer application data
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-COMMAND: Invoking this->templateInstance->assignApplicationData() ...');
$this->getTemplateInstance()->assignApplicationData();
// Assign base URL
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-COMMAND: Invoking this->templateInstance->assignConfigVariable(base_url) ...');
$this->getTemplateInstance()->assignConfigVariable('base_url');
+ // Get the application instance
+ $applicationInstance = ApplicationHelper::getSelfInstance();
+
// Load the master template
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-COMMAND: applicationInstance=%s', $applicationInstance->__toString()));
$masterTemplate = $applicationInstance->buildMasterTemplateName();
// Load header template
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-COMMAND: masterTemplate=%s', $masterTemplate));
$this->getTemplateInstance()->loadCodeTemplate('header');
// Compile and assign it with a variable
// Set title
$this->getTemplateInstance()->assignVariable('title', FrameworkBootstrap::getLanguageInstance()->getMessage('page_' . $applicationInstance->getAppShortName() . '_' . $this->getResolverInstance()->getCommandName() . '_title'));
- // Construct the menu in every command. We could do this in BaseCommand class. But this means
- // *every* command has a navigation system and that is want we don't want.
+ /*
+ * Construct the menu in every command. We could do this in BaseCommand
+ * class. But this means *every* command has a navigation system and
+ * that is want we don't want.
+ */
$menuInstance = ObjectFactory::createObjectByConfiguredName($applicationInstance->getAppShortName() . '_' . $this->getResolverInstance()->getCommandName() . '_menu_class');
// Render the menu
// Get the content back from the template engine and put it in response class
$this->getTemplateInstance()->transferToResponse($responseInstance);
+
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-COMMAND: EXIT!');
}
}
<?php
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
+
/**
* A ??? console command
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
* @return void
*/
public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- $this->partialStub('Unfinished!');
+ DebugMiddleware::getSelfInstance()->partialStub('Unfinished!');
}
/**
* @return void
*/
public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
- $this->partialStub('Unfinished!');
+ DebugMiddleware::getSelfInstance()->partialStub('Unfinished!');
}
}
use Org\Mxchange\CoreFramework\Command\Commandable;
use Org\Mxchange\CoreFramework\Controller\Controller;
use Org\Mxchange\CoreFramework\Feature\FrameworkFeature;
+use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
use Org\Mxchange\CoreFramework\Request\Requestable;
use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver;
use Org\Mxchange\CoreFramework\Response\Responseable;
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
}
// @TODO Unfinished
- $this->partialStub('Still unfinished! ;-)');
+ DebugMiddleware::getSelfInstance()->partialStub('Still unfinished! ;-)');
}
/**
<?php
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
+
/**
* A command for ??? page
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
* @todo 0% done
*/
public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- $this->partialStub('Unfinished method.');
+ DebugMiddleware::getSelfInstance()->partialStub('Unfinished method.');
}
/**
use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
use Org\Mxchange\CoreFramework\Generic\NullPointerException;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
+use Org\Mxchange\CoreFramework\Registry\Object\ObjectRegistry;
use Org\Mxchange\CoreFramework\Request\Requestable;
use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver;
use Org\Mxchange\CoreFramework\Response\Responseable;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Get user instance
try {
- $userInstance = GenericRegistry::getRegistry()->getInstance('user');
+ $userInstance = ObjectRegistry::getRegistry('generic')->getInstance('user');
} catch (NullPointerException $e) {
// Not found user, e.g. when the user is somehow invalid
$responseInstance->redirectToConfiguredUrl('html_cmd_user_is_null');
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
use Org\Mxchange\CoreFramework\Controller\Controller;
use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
use Org\Mxchange\CoreFramework\Request\Requestable;
use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver;
use Org\Mxchange\CoreFramework\Response\Responseable;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
use Org\Mxchange\CoreFramework\Controller\Controller;
use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
+use Org\Mxchange\CoreFramework\Registry\Object\ObjectRegistry;
use Org\Mxchange\CoreFramework\Request\Requestable;
use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver;
use Org\Mxchange\CoreFramework\Response\Responseable;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*/
public function execute (Requestable $requestInstance, Responseable $responseInstance) {
// Get the action instance from registry
- $actionInstance = GenericRegistry::getRegistry()->getInstance('action');
+ $actionInstance = ObjectRegistry::getRegistry('generic')->getInstance('action');
// Do we have an action here?
if ($actionInstance instanceof PerformableAction) {
$actionInstance->addExtraFilters($controllerInstance, $requestInstance);
// Remember this action in registry
- GenericRegistry::getRegistry()->addInstance('action', $actionInstance);
+ ObjectRegistry::getRegistry('generic')->addInstance('action', $actionInstance);
}
}
use Org\Mxchange\CoreFramework\Controller\Controller;
use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
+use Org\Mxchange\CoreFramework\Registry\Object\ObjectRegistry;
use Org\Mxchange\CoreFramework\Request\Requestable;
use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver;
use Org\Mxchange\CoreFramework\Response\Responseable;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*/
public function execute (Requestable $requestInstance, Responseable $responseInstance) {
// Set request instance as extra instance
- GenericRegistry::getRegistry()->addInstance('extra', $this);
+ ObjectRegistry::getRegistry('generic')->addInstance('extra', $this);
// Get the application instance
$applicationInstance = ApplicationHelper::getSelfInstance();
use Org\Mxchange\CoreFramework\Controller\Controller;
use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
use Org\Mxchange\CoreFramework\Request\Requestable;
use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver;
use Org\Mxchange\CoreFramework\Response\Responseable;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
use Org\Mxchange\CoreFramework\Command\Commandable;
use Org\Mxchange\CoreFramework\Controller\Controller;
use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
use Org\Mxchange\CoreFramework\Request\Requestable;
use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver;
use Org\Mxchange\CoreFramework\Response\Responseable;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
use Org\Mxchange\CoreFramework\Controller\Controller;
use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
use Org\Mxchange\CoreFramework\Request\Requestable;
use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver;
use Org\Mxchange\CoreFramework\Response\Responseable;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
use Org\Mxchange\CoreFramework\Command\BaseCommand;
use Org\Mxchange\CoreFramework\Command\Commandable;
use Org\Mxchange\CoreFramework\Controller\Controller;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
+use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
use Org\Mxchange\CoreFramework\Request\Requestable;
use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver;
use Org\Mxchange\CoreFramework\Response\Responseable;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
* @todo 0% done
*/
public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- $this->partialStub('Unfinished method.');
+ DebugMiddleware::getSelfInstance()->partialStub('Unfinished method.');
}
/**
use Org\Mxchange\CoreFramework\Controller\Controller;
use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
+use Org\Mxchange\CoreFramework\Registry\Object\ObjectRegistry;
use Org\Mxchange\CoreFramework\Request\Requestable;
use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver;
use Org\Mxchange\CoreFramework\Response\Responseable;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*/
public function execute (Requestable $requestInstance, Responseable $responseInstance) {
// Set request instance as extra instance
- GenericRegistry::getRegistry()->addInstance('extra', $this);
+ ObjectRegistry::getRegistry('generic')->addInstance('extra', $this);
// Get the application instance
$applicationInstance = ApplicationHelper::getSelfInstance();
use Org\Mxchange\CoreFramework\Database\Frontend\User\UserDatabaseFrontend;
use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
+use Org\Mxchange\CoreFramework\Helper\Crypto\CryptoHelper;
+use Org\Mxchange\CoreFramework\Registry\Object\ObjectRegistry;
use Org\Mxchange\CoreFramework\Request\Requestable;
use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver;
use Org\Mxchange\CoreFramework\Response\Responseable;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*/
public function execute (Requestable $requestInstance, Responseable $responseInstance) {
// Get user instance from registry
- $userInstance = GenericRegistry::getRegistry()->getInstance('user');
+ $userInstance = ObjectRegistry::getRegistry('generic')->getInstance('user');
// Get an application instance
$applicationInstance = ApplicationHelper::getSelfInstance();
$randomString = $rngInstance->randomString(255);
// Get a crypto instance
- $cryptoInstance = ObjectFactory::createObjectByConfiguredName('crypto_class');
+ $cryptoInstance = CryptoHelper::getSelfInstance();
// Hash and encrypt the string
$hashedString = $cryptoInstance->hashString($cryptoInstance->encryptString($randomString));
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
use Org\Mxchange\CoreFramework\Command\Commandable;
use Org\Mxchange\CoreFramework\Controller\Controller;
use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
use Org\Mxchange\CoreFramework\Request\Requestable;
use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver;
use Org\Mxchange\CoreFramework\Response\Responseable;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
use Org\Mxchange\CoreFramework\Compressor\Compressor;
use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
-// Load SPL stuff
-use \InvalidArgumentException;
-
/**
* BZIP2 compression and decompression class
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
$compressorInstance = NULL;
// Get new instance
- if ((function_exists('bzcompress')) && (function_exists('bzdecompress'))) {
+ if (extension_loaded('bzip2')) {
// Compressor can maybe be used
$compressorInstance = new Bzip2Compressor();
}
*
* @param $streamData Mixed non-object stream data
* @return $streamData The compressed stream data
- * @throws InvalidArgumentException If the stream is not compressable or decompressable
*/
public function compressStream (string $streamData) {
- // Validate parameter
- if (is_object($streamData) || is_resource($streamData)) {
- // Throw an exception
- throw new InvalidArgumentException(sprintf('streamData[]=%s cannot be compressed/decompressed', gettype($streamData)));
- }
+ // Compress it
+ $streamData = bzcompress($streamData, 1);
// Return the compressed stream
- return bzcompress($streamData, 1);
+ return $streamData;
}
/**
*
* @param $streamData Mixed non-object stream data
* @return $streamData The decompressed stream data
- * @throws InvalidArgumentException If the stream is not compressable or decompressable
*/
public function decompressStream (string $streamData) {
- // Validate parameter
- if (is_object($streamData) || is_resource($streamData)) {
- // Throw an exception
- 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
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @param $streamData Mixed non-object stream data
* @return $streamData The compressed stream data
- * @throws InvalidArgumentException If the stream is not compressable or decompressable
*/
public function compressStream (string $streamData) {
- // Validate parameter
- if (is_object($streamData) || is_resource($streamData)) {
- // Throw an exception
- throw new InvalidArgumentException(sprintf('streamData[]=%s cannot be compressed/decompressed', gettype($streamData)));
- }
+ // Compress stream
+ $streamData = gzencode($streamData, 1);
- // Return the compressed stream
- return gzencode($streamData, 1);
+ // Return it
+ return $streamData;
}
/**
*
* @param $streamData Mixed non-object stream data
* @return $streamData The decompressed stream data
- * @throws InvalidArgumentException If the stream is not compressable or decompressable
*/
public function decompressStream (string $streamData) {
- // Validate parameter
- if (is_object($streamData) || is_resource($streamData)) {
- // Throw an exception
- throw new InvalidArgumentException(sprintf('streamData[]=%s cannot be compressed/decompressed', gettype($streamData)));
- }
+ // Decompress string
+ $streamData = gzdecode($streamData);
- // Return the decompressed stream
- return gzdecode($streamData);
+ // Return it
+ return $streamData;
}
/**
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
use Org\Mxchange\CoreFramework\Compressor\Compressor;
use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
-// Load SPL stuff
-use \InvalidArgumentException;
-
/**
* ZLIB compression and decompression class
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @param $streamData Mixed non-object stream data
* @return $streamData The compressed stream data
- * @throws InvalidArgumentException If the stream is not compressable or decompressable
*/
public function compressStream (string $streamData) {
- // Validate parameter
- if (is_object($streamData) || is_resource($streamData)) {
- // Throw an exception
- throw new InvalidArgumentException(sprintf('streamData[]=%s cannot be compressed/decompressed', gettype($streamData)));
- }
+ // Compress string
+ $streamData = gzcompress($streamData, 1);
- // Return the compressed stream
- return gzcompress($streamData, 1);
+ // Return it
+ return $streamData;
}
/**
*
* @param $streamData Mixed non-object stream data
* @return $streamData The decompressed stream data
- * @throws InvalidArgumentException If the stream is not compressable or decompressable
*/
public function decompressStream (string $streamData) {
- // Validate parameter
- if (is_object($streamData) || is_resource($streamData)) {
- // Throw an exception
- throw new InvalidArgumentException(sprintf('streamData[]=%s cannot be compressed/decompressed', gettype($streamData)));
- }
-
// Return the decompressed stream
- return gzuncompress($streamData);
+ $streamData = gzuncompress($streamData);
+
+ // Return it
+ return $streamData;
}
/**
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
namespace Org\Mxchange\CoreFramework\Controller;
// Import framework stuff
-use Org\Mxchange\CoreFramework\Chain\Filter\InvalidFilterChainException;
use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
use Org\Mxchange\CoreFramework\Filter\Filterable;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
+use Org\Mxchange\CoreFramework\Registry\Object\ObjectRegistry;
use Org\Mxchange\CoreFramework\Registry\Registerable;
use Org\Mxchange\CoreFramework\Request\Requestable;
use Org\Mxchange\CoreFramework\Response\Responseable;
use Org\Mxchange\CoreFramework\Traits\Resolver\ResolverTrait;
+// Import SPL stuff
+use \BadMethodCallException;
+use \InvalidArgumentException;
+
/**
* A generic controller class. You should extend this base class if you want to
* write your own controller. You get the advantage that you can use the pre and
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Names of controller's own filter chains
const FILTER_CHAIN_PRE_COMMAND = 'controller_pre_command';
const FILTER_CHAIN_POST_COMMAND = 'controller_post_command';
+ const FILTER_CHAIN_SHUTDOWN = 'shutdown';
/**
* Generic filter chains
*/
protected function __construct (string $className) {
// Call parent constructor
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-CONTROLLER: className=%s - CONSTRUCTED!', $className));
parent::__construct($className);
// Initialize both filter chains
- $this->initFilterChain(self::FILTER_CHAIN_PRE_COMMAND);
- $this->initFilterChain(self::FILTER_CHAIN_POST_COMMAND);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('BASE-CONTROLLER: Initializing filter chains ...');
+ foreach([self::FILTER_CHAIN_PRE_COMMAND, self::FILTER_CHAIN_POST_COMMAND] as $filterChain) {
+ // Init it
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-CONTROLLER: Invoking this->initFilterChain(=%s) ...', $filterChain));
+ $this->initFilterChain($filterChain);
+ }
// Add this controller to the registry
- GenericRegistry::getRegistry()->addInstance('controller', $this);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-CONTROLLER: Registering this=%s ...', $this->__toString()));
+ ObjectRegistry::getRegistry('generic')->addInstance('controller', $this);
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-CONTROLLER: EXIT!');
}
/**
*/
public function executeGenericPrePostCommand (Requestable $requestInstance, Responseable $responseInstance) {
// Get the command instance from the resolver by sending a request instance to the resolver
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-CONTROLLER: requestInstance=%s,responseInstance=%s - CALLED!', $requestInstance->__toString(), $responseInstance->__toString()));
$commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance);
// Add more filters by the command
$this->executePreFilters($requestInstance, $responseInstance);
// This request was valid! :-D
- $requestInstance->requestIsValid();
+ $requestInstance->setIsRequestValid(TRUE);
// Execute the command
$commandInstance->execute($requestInstance, $responseInstance);
// Flush the response out
$responseInstance->flushBuffer();
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-CONTROLLER: EXIT!');
}
/**
*/
public function genericHanleRequestLoginFailedRedirect (Requestable $requestInstance, Responseable $responseInstance) {
// Get the "form action"
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-CONTROLLER: requestInstance=%s,responseInstance=%s - CALLED!', $requestInstance->__toString(), $responseInstance->__toString()));
$formAction = $requestInstance->getRequestElement('form');
// Get command instance from resolver
$responseInstance->redirectToConfiguredUrl('login_failed');
// Exit here
- exit();
+ exit;
}
/*
// Flush the buffer out
$responseInstance->flushBuffer();
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-CONTROLLER: EXIT!');
}
/**
*/
public function genericHanleRequestLoginAreaFailedRedirect (Requestable $requestInstance, Responseable $responseInstance) {
// Get the command instance from the resolver by sending a request instance to the resolver
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-CONTROLLER: requestInstance=%s,responseInstance=%s - CALLED!', $requestInstance->__toString(), $responseInstance->__toString()));
$commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance);
// Add more filters by the command
$responseInstance->redirectToConfiguredUrl('login_failed');
// Exit here
- exit();
+ exit;
}
// This request was valid! :-D
- $requestInstance->requestIsValid();
+ $requestInstance->setIsRequestValid(TRUE);
// Execute the command
$commandInstance->execute($requestInstance, $responseInstance);
// Flush the response out
$responseInstance->flushBuffer();
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-CONTROLLER: EXIT!');
}
/**
*
* @param $filterChain Name of the filter chain
* @return void
+ * @throws InvalidArgumentException If a parameter has an invalid value
+ * @throws BadMethodCallException If the given filter chain is already initialized
*/
protected function initFilterChain (string $filterChain) {
- //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONTROLLER: ' . $filterChain . ' init: START');
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-CONTROLLER: filterChain=%s - CALLED!', $filterChain));
+ if (empty($filterChain)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "filterChain" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (isset($this->filterChains[$filterChain])) {
+ // Throw BMCE
+ throw new BadMethodCallException(sprintf('filterChain=%s is already initialized', $filterChain), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
+ }
+
+ // Initialize filter chain
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-CONTROLLER: Initializing filterChain=%s ...', $filterChain));
$this->filterChains[$filterChain] = ObjectFactory::createObjectByConfiguredName('filter_chain_class');
- //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONTROLLER: ' . $filterChain . ' init: FINISHED');
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-CONTROLLER: EXIT!');
}
/**
* @param $filterChain Chain of the filter
* @param $filterInstance An instance of a filter
* @return void
- * @throws InvalidFilterChainException If the filter chain is invalid
+ * @throws InvalidArgumentException If a parameter has an invalid value
+ * @throws BadMethodCallException If the given filter chain is not yet initialized
*/
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
- if (!isset($this->filterChains[$filterChain])) {
- // Throw an exception here
- throw new InvalidFilterChainException(array($this, $filterChain), self::EXCEPTION_FILTER_CHAIN_INVALID);
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-CONTROLLER: filterChain=%s,filterInstance=%s - CALLED!', $filterChain, $filterInstance->__toString()));
+ if (empty($filterChain)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "filterChain" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (!isset($this->filterChains[$filterChain])) {
+ // Throw IAE
+ throw new BadMethodCallException(sprintf('filterChain=%s is not a valid chain', $filterChain), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
}
// Add the filter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-CONTROLLER: Adding filterInstance=%s to filterChain=%s ...', $filterInstance->__toString(), $filterChain));
$this->filterChains[$filterChain]->addFilter($filterInstance);
- //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONTROLLER: ' . $filterChain . ',' . $filterInstance->__toString(). ' add: FINISH');
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-CONTROLLER: EXIT!');
}
/**
*/
public function addPreFilter (Filterable $filterInstance) {
// Add the pre filter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-CONTROLLER: filterInstance=%s - CALLED!', $filterInstance->__toString()));
$this->addFilter(self::FILTER_CHAIN_PRE_COMMAND, $filterInstance);
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-CONTROLLER: EXIT!');
}
/**
* @return void
*/
public function addPostFilter (Filterable $filterInstance) {
- // Add the post filter
+ // Add post filter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-CONTROLLER: filterInstance=%s - CALLED!', $filterInstance->__toString()));
$this->addFilter(self::FILTER_CHAIN_POST_COMMAND, $filterInstance);
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-CONTROLLER: EXIT!');
}
/**
* @return void
*/
public function addShutdownFilter (Filterable $filterInstance) {
- $this->addFilter('shutdown', $filterInstance);
+ // Add shutdown filter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-CONTROLLER: filterInstance=%s - CALLED!', $filterInstance->__toString()));
+ $this->addFilter(self::FILTER_CHAIN_SHUTDOWN, $filterInstance);
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-CONTROLLER: EXIT!');
}
/**
* @param $requestInstance An instance of a Requestable class
* @param $responseInstance An instance of a Responseable class
* @return void
- * @throws InvalidFilterChainException If the filter chain is invalid
+ * @throws InvalidArgumentException If the filter chain is invalid
*/
protected function executeFilters (string $filterChain, Requestable $requestInstance, Responseable $responseInstance) {
- // Test if the filter is there
- if (!isset($this->filterChains[$filterChain])) {
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-CONTROLLER: filterChain=%s,requestInstance=%s,responseInstance=%s - CALLED!', $filterChain, $requestInstance->__toString(), $responseInstance->__toString()));
+ if (empty($filterChain)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "filterChain" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (!isset($this->filterChains[$filterChain])) {
// Throw an exception here
- throw new InvalidFilterChainException(array($this, $filterChain), self::EXCEPTION_FILTER_CHAIN_INVALID);
+ throw new BadMethodCallException(sprintf('filterChain=%s is not a valid chain', $filterChain), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
}
// Run all filters
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-CONTROLLER: Processing filterChain=%s...', $filterChain));
$this->filterChains[$filterChain]->processFilters($requestInstance, $responseInstance);
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-CONTROLLER: EXIT!');
}
/**
*/
protected function executePreFilters (Requestable $requestInstance, Responseable $responseInstance) {
// Execute all pre filters
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-CONTROLLER: requestInstance=%s,responseInstance=%s - CALLED!', $requestInstance->__toString(), $responseInstance->__toString()));
$this->executeFilters(self::FILTER_CHAIN_PRE_COMMAND, $requestInstance, $responseInstance);
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-CONTROLLER: EXIT!');
}
/**
*/
protected function executePostFilters (Requestable $requestInstance, Responseable $responseInstance) {
// Execute all post filters
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-CONTROLLER: requestInstance=%s,responseInstance=%s - CALLED!', $requestInstance->__toString(), $responseInstance->__toString()));
$this->executeFilters(self::FILTER_CHAIN_POST_COMMAND, $requestInstance, $responseInstance);
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-CONTROLLER: EXIT!');
}
/**
* @return void
*/
public function executeShutdownFilters (Requestable $requestInstance, Responseable $responseInstance) {
- $this->executeFilters('shutdown', $requestInstance, $responseInstance);
+ // Execute all shutdown filter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-CONTROLLER: requestInstance=%s,responseInstance=%s - CALLED!', $requestInstance->__toString(), $responseInstance->__toString()));
+ $this->executeFilters(self::FILTER_CHAIN_SHUTDOWN, $requestInstance, $responseInstance);
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-CONTROLLER: EXIT!');
}
}
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @todo This controller shall still provide some headlines for sidebars
$commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance);
// This request was valid! :-D
- $requestInstance->requestIsValid();
+ $requestInstance->setIsRequestValid(TRUE);
// Execute the command
$commandInstance->execute($requestInstance, $responseInstance);
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @todo This controller shall still provide some headlines for sidebars
$commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance);
// This request was valid! :-D
- $requestInstance->requestIsValid();
+ $requestInstance->setIsRequestValid(TRUE);
// Execute the command
$commandInstance->execute($requestInstance, $responseInstance);
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
$commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance);
// This request was valid! :-D
- $requestInstance->requestIsValid();
+ $requestInstance->setIsRequestValid(TRUE);
// Execute the command
$commandInstance->execute($requestInstance, $responseInstance);
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @todo This controller shall still provide some headlines for sidebars
$commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance);
// This request was valid! :-D
- $requestInstance->requestIsValid();
+ $requestInstance->setIsRequestValid(TRUE);
// Execute the command
$commandInstance->execute($requestInstance, $responseInstance);
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @todo This controller shall still provide some headlines for sidebars
$commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance);
// This request was valid! :-D
- $requestInstance->requestIsValid();
+ $requestInstance->setIsRequestValid(TRUE);
// Execute the command
$commandInstance->execute($requestInstance, $responseInstance);
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
$commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance);
// This request was valid! :-D
- $requestInstance->requestIsValid();
+ $requestInstance->setIsRequestValid(TRUE);
// Execute the command
$commandInstance->execute($requestInstance, $responseInstance);
// Import framework stuff
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
use Org\Mxchange\CoreFramework\Criteria\Search\SearchCriteria;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
use Org\Mxchange\CoreFramework\Utils\Strings\StringUtils;
+// Import SPL stuff
+use \BadMethodCallException;
+use \InvalidArgumentException;
+use \UnexpectedValueException;
+
/**
* A general crtieria class
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*/
private $frontendConfigEntry = '';
+ /**
+ * All supported criteria types
+ */
+ private static $CRITERIA_TYPES = [];
+
/**
* Protected constructor
*
*/
protected function __construct (string $className) {
// Call parent constructor
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-CRITERIA: className=%s - CONSTRUCTED!', $className));
parent::__construct($className);
+ // Initialize valid criteria types array
+ self::$CRITERIA_TYPES = [Criteria::CRITERIA_TYPE_DEFAULT, Criteria::CRITERIA_TYPE_CHOICE, Criteria::CRITERIA_TYPE_EXCLUDE];
+
// Initialize all criteria arrays
- foreach (array('default', 'choice', 'exclude') as $criteriaType) {
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-CRITERIA: self::CRITERIA_TYPES()=%d', count(self::$CRITERIA_TYPES)));
+ foreach (self::$CRITERIA_TYPES as $criteriaType) {
// Init it
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-CRITERIA: Invoking this->initGenericArrayKey(criteria,%s,entries) ...', $criteriaType));
$this->initGenericArrayKey('criteria', $criteriaType, 'entries');
}
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-CRITERIA: EXIT!');
}
/**
*
* @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
* @return $count Count of all criteria entries
+ * @throws InvalidArgumentException If a parameter is not valid
*/
- protected final function count (string $criteriaType = 'default') {
- // Return it
+ protected final function count (string $criteriaType = Criteria::CRITERIA_TYPE_DEFAULT) {
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-CRITERIA: criteriaType=%s - CALLED!', strtoupper($criteriaType), $criteriaType));
+ if (empty($criteriaType)) {
+ // Throw it again
+ throw new InvalidArgumentException('Parameter "criteriaType" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (!in_array($criteriaType, self::$CRITERIA_TYPES)) {
+ // Throw it again
+ throw new InvalidArgumentException(sprintf('criteriaType=%s is not supported', $criteriaType));
+ }
+
+ // Invoke inner method
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-CRITERIA: Invoking this->countGenericArrayGroup(criteria, %s) ... - EXIT!', strtoupper($criteriaType), $criteriaType));
return $this->countGenericArrayGroup('criteria', $criteriaType);
}
*
* @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
* @param $criteriaKey Criteria key
- * @return $isSet Whether key is set
+ * @return $isset Whether key is set
+ * @throws InvalidArgumentException If a parameter is not valid
+ * @throws UnexpectedValueException If a parameter contains an unexpected/unsupported value
*/
public function isKeySet (string $criteriaType, string $criteriaKey) {
- // Make sure no 'my-' or 'my_' passes this point
- assert((strpos($criteriaKey, 'my-') === false) && (strpos($criteriaKey, 'my_') === false));
+ // Check parameters
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-CRITERIA: criteriaType=%s,criteriaKey=%s - CALLED!', strtoupper($criteriaType), $criteriaType, $criteriaKey));
+ if (empty($criteriaType)) {
+ // Throw it again
+ throw new InvalidArgumentException('Parameter "criteriaType" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (!in_array($criteriaType, self::$CRITERIA_TYPES)) {
+ // Throw it again
+ throw new UnexpectedValueException(sprintf('criteriaType=%s is not supported', $criteriaType), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
+ } elseif (empty($criteriaKey)) {
+ // Throw it again
+ throw new InvalidArgumentException('Parameter "criteriaKey" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif ((strpos($criteriaKey, 'my-') !== false) || (strpos($criteriaKey, 'my_') !== false)) {
+ // Throw it again
+ throw new InvalidArgumentException(sprintf('criteriaKey=%s has illegal prefix "my"', $criteriaKey));
+ }
// Determine it
- $isSet = $this->isGenericArrayElementSet('criteria', $criteriaType, 'entries', $criteriaKey);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('%s-CRITERIA: Invoking this->isGenericArrayElementSet(criteria,%s,entries,%s) ...', strtoupper($criteriaType), $criteriaType, $criteriaKey));
+ $isset = $this->isGenericArrayElementSet('criteria', $criteriaType, 'entries', $criteriaKey);
// Return it
- return $isSet;
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-CRITERIA: isset=%d - EXIT!', strtoupper($criteriaType), intval($isset)));
+ return $isset;
}
/**
* Checks whether given key is set for 'choice' type
*
* @param $criteriaKey Criteria key
- * @return $isSet Whether key is set
+ * @return $isset Whether key is set
+ * @throws InvalidArgumentException If a parameter is not valid
*/
public function isChoiceKeySet (string $criteriaKey) {
- // Call inner method
- return $this->isKeySet('choice', $criteriaKey);
+ // Validate parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-CRITERIA: criteriaKey=%s - CALLED!', $criteriaKey));
+ if (empty($criteriaKey)) {
+ // Throw it again
+ throw new InvalidArgumentException('Parameter "criteriaKey" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
+ // Invoke inner method
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-CRITERIA: Invoking this->isKeySet(%s,%s) ...', Criteria::CRITERIA_TYPE_CHOICE, $criteriaKey));
+ return $this->isKeySet(Criteria::CRITERIA_TYPE_CHOICE, $criteriaKey);
}
/**
* Checks whether given key is set for 'exclude' type
*
* @param $criteriaKey Criteria key
- * @return $isSet Whether key is set
+ * @return $isset Whether key is set
+ * @throws InvalidArgumentException If a parameter is not valid
*/
public function isExcludeKeySet (string $criteriaKey) {
- // Call inner method
- return $this->isKeySet('exclude', $criteriaKey);
+ // Validate parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-CRITERIA: criteriaKey=%s - CALLED!', $criteriaKey));
+ if (empty($criteriaKey)) {
+ // Throw it again
+ throw new InvalidArgumentException('Parameter "criteriaKey" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
+ // Invoke inner method
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-CRITERIA: Invoking this->isKeySet(%s,%s) ... - EXIT!', Criteria::CRITERIA_TYPE_EXCLUDE, $criteriaKey));
+ return $this->isKeySet(Criteria::CRITERIA_TYPE_EXCLUDE, $criteriaKey);
}
/**
*
* @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
* @return $criteria
+ * @throws InvalidArgumentException If a parameter is not valid
+ * @throws UnexpectedValueException If a parameter contains an unexpected/unsupported value
*/
- public final function getCriteriaArray (string $criteriaType = 'default') {
+ public final function getCriteriaArray (string $criteriaType = Criteria::CRITERIA_TYPE_DEFAULT) {
+ // Check parameters
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-CRITERIA: criteriaType=%s - CALLED!', strtoupper($criteriaType), $criteriaType));
+ if (empty($criteriaType)) {
+ // Throw it again
+ throw new InvalidArgumentException('Parameter "criteriaType" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (!in_array($criteriaType, self::$CRITERIA_TYPES)) {
+ // Throw it again
+ throw new UnexpectedValueException(sprintf('criteriaType=%s is not supported', $criteriaType), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
+ }
+
+ // Invoke inner method
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-CRITERIA: Invoking this->getGenericArrayKey(criteria,%s,entries) ... - EXIT!', strtoupper($criteriaType), $criteriaType));
return $this->getGenericArrayKey('criteria', $criteriaType, 'entries');
}
* @return $criteria
*/
public final function getCriteriaChoiceArray () {
- return $this->getCriteriaArray('choice');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-CRITERIA: CALLED!', strtoupper($criteriaType)));
+ return $this->getCriteriaArray(Criteria::CRITERIA_TYPE_CHOICE);
}
/**
* @return $criteria
*/
public final function getCriteriaExcludeArray () {
- return $this->getCriteriaArray('exclude');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-CRITERIA: CALLED!');
+ return $this->getCriteriaArray(Criteria::CRITERIA_TYPE_EXCLUDE);
}
/**
* @return void
*/
public final function unsetCriteria (string $criteriaKey) {
- // Make sure no 'my-' or 'my_' passes this point
- assert((strpos($criteriaKey, 'my-') === false) && (strpos($criteriaKey, 'my_') === false));
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-CRITERIA: criteriaKey=%s - CALLED!', $criteriaKey));
+ if (empty($criteriaKey)) {
+ // Throw it again
+ throw new InvalidArgumentException('Parameter "criteriaKey" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif ((strpos($criteriaKey, 'my-') !== false) || (strpos($criteriaKey, 'my_') !== false)) {
+ // Throw it again
+ throw new InvalidArgumentException(sprintf('criteriaKey=%s has illegal prefix "my"', $criteriaKey));
+ }
// Convert dashes to underscore
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-CRITERIA: Invoking StringUtils::convertDashesToUnderscores(%s) ...', strtoupper($criteriaType), $criteriaKey));
$criteriaKey = StringUtils::convertDashesToUnderscores($criteriaKey);
// "Walk" through all criterias
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('%s-CRITERIA: criteriaKey=%s', strtoupper($criteriaType), $criteriaKey));
foreach ($this->getGenericArray('criteria') as $criteriaType => $dummy) {
// Remove it
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-CRITERIA: Removing criteriaType=%s,criteriaKey=%s ...', strtoupper($criteriaType), $criteriaType, $criteriaKey));
$this->unsetGenericArrayElement('criteria', $criteriaType, 'entries', $criteriaKey);
}
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-CRITERIA: EXIT!');
}
/**
* @param $criteriaValue Criteria value
* @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
* @return void
+ * @throws InvalidArgumentException If a parameter is not valid
+ * @throws UnexpectedValueException If a parameter contains an unexpected/unsupported value
*/
- public final function addCriteria (string $criteriaKey, $criteriaValue, string $criteriaType = 'default') {
- // Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($criteriaType) . '-CRITERIA: criteriaKey=' . $criteriaKey . ',criteriaValue=' . $criteriaValue . ',criteriaType=' . $criteriaType . ' - CALLED!');
-
- // Make sure no 'my-' or 'my_' passes this point
- assert((strpos($criteriaKey, 'my-') === false) && (strpos($criteriaKey, 'my_') === false) && (!is_bool($criteriaValue)));
+ public final function addCriteria (string $criteriaKey, $criteriaValue, string $criteriaType = Criteria::CRITERIA_TYPE_DEFAULT) {
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-CRITERIA: criteriaKey=%s,criteriaValue[]=%s,criteriaType=%s - CALLED!', strtoupper($criteriaType), $criteriaKey, gettype($criteriaValue), $criteriaType));
+ if (empty($criteriaKey)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "criteriaKey" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif ((strpos($criteriaKey, 'my-') !== false) || (strpos($criteriaKey, 'my_') !== false)) {
+ // Throw it again
+ throw new InvalidArgumentException(sprintf('criteriaKey=%s has illegal prefix "my"', $criteriaKey));
+ } elseif (is_array($criteriaValue) || is_bool($criteriaValue) || is_object($criteriaValue) || is_resource($criteriaValue)) {
+ // Throw it again
+ throw new InvalidArgumentException(sprintf('value[]=%s is not supported', gettype($criteriaValue)));
+ } elseif (empty($criteriaType)) {
+ // Throw it again
+ throw new InvalidArgumentException('Parameter "criteriaType" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (!in_array($criteriaType, self::$CRITERIA_TYPES)) {
+ // Throw it again
+ throw new UnexpectedValueException(sprintf('criteriaType=%s is not supported', $criteriaType), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
+ }
// Convert dashes to underscore
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-CRITERIA: Invoking StringUtils::convertDashesToUnderscores(%s) ...', strtoupper($criteriaType), $criteriaKey));
$criteriaKey = StringUtils::convertDashesToUnderscores($criteriaKey);
- // Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($criteriaType) . '(' . $this->__toString() . ')-CRITERIA: criteriaKey=' . $criteriaKey);
+ // Set it
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-CRITERIA: Invoking this->setGenericArrayElement(criteria,%s,entries,%s,criteriaValue[]=%s) ...', strtoupper($criteriaType), $criteriaType, $criteriaKey, gettype($criteriaValue)));
+ $this->setGenericArrayElement('criteria', $criteriaType, 'entries', $criteriaKey, $criteriaValue);
- // Append it
- $this->appendStringToGenericArrayElement('criteria', $criteriaType, 'entries', $criteriaKey, $criteriaValue);
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-CRITERIA: EXIT!', strtoupper($criteriaType)));
}
/**
* @param $criteriaValue Criteria value
* @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
* @return void
+ * @throws InvalidArgumentException If a parameter is not valid
+ * @throws UnexpectedValueException If a parameter contains an unexpected/unsupported value
*/
- public final function setCriteria (string $criteriaKey, $criteriaValue, string $criteriaType = 'default') {
- // Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($criteriaType) . '-CRITERIA: criteriaKey=' . $criteriaKey . ',criteriaValue=' . $criteriaValue . ',criteriaType=' . $criteriaType . ' - CALLED!');
-
- // Make sure no 'my-' or 'my_' passes this point
- assert((strpos($criteriaKey, 'my-') === false) && (strpos($criteriaKey, 'my_') === false) && (!is_bool($criteriaValue)));
+ public final function setCriteria (string $criteriaKey, $criteriaValue, string $criteriaType = Criteria::CRITERIA_TYPE_DEFAULT) {
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-CRITERIA: criteriaKey=%s,criteriaValue[]=%s$criteriaValue,criteriaType=%s - CALLED!', strtoupper($criteriaType), $criteriaKey, gettype($criteriaValue), $criteriaType));
+ if (empty($criteriaKey)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "criteriaKey" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif ((strpos($criteriaKey, 'my-') !== false) || (strpos($criteriaKey, 'my_') !== false)) {
+ // Throw it again
+ throw new InvalidArgumentException(sprintf('criteriaKey=%s has illegal prefix "my"', $criteriaKey));
+ } elseif (is_array($criteriaValue) || is_bool($criteriaValue) || is_object($criteriaValue) || is_resource($criteriaValue)) {
+ // Throw it again
+ throw new InvalidArgumentException(sprintf('value[]=%s is not supported', gettype($criteriaValue)));
+ } elseif (empty($criteriaType)) {
+ // Throw it again
+ throw new InvalidArgumentException('Parameter "criteriaType" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (!in_array($criteriaType, self::$CRITERIA_TYPES)) {
+ // Throw it again
+ throw new UnexpectedValueException(sprintf('criteriaType=%s is not supported', $criteriaType), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
+ }
// Convert dashes to underscore
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-CRITERIA: Invoking StringUtils::convertDashesToUnderscores(%s) ...', strtoupper($criteriaType), $criteriaKey));
$criteriaKey = StringUtils::convertDashesToUnderscores($criteriaKey);
- // Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($criteriaType) . '(' . $this->__toString() . ')-CRITERIA: criteriaKey=' . $criteriaKey);
-
// Set it
- $this->setStringGenericArrayElement('criteria', $criteriaType, 'entries', $criteriaKey, $criteriaValue);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-CRITERIA: Invoking this->setGenericArrayElement(criteria,%s,entries,%s,criteriaValue[]=%s) ...', strtoupper($criteriaType), $criteriaKey, gettype($criteriaValue)));
+ $this->setGenericArrayElement('criteria', $criteriaType, 'entries', $criteriaKey, $criteriaValue);
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-CRITERIA: EXIT!');
}
/**
* @param $criteriaKey Criteria key
* @param $criteriaValue Criteria value
* @return void
+ * @throws InvalidArgumentException If a parameter is not valid
+ * @throws UnexpectedValueException If $criteriaValue has an unexpected type
*/
public final function addChoiceCriteria (string $criteriaKey, $criteriaValue) {
- // Make sure no 'my-' or 'my_' passes this point
- assert((strpos($criteriaKey, 'my-') === false) && (strpos($criteriaKey, 'my_') === false) && (!is_bool($criteriaValue)));
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-CRITERIA: criteriaKey=%s,criteriaValue[]=%s - CALLED!', $criteriaKey, gettype($criteriaValue)));
+ if (empty($criteriaKey)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "criteriaKey" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif ((strpos($criteriaKey, 'my-') !== false) || (strpos($criteriaKey, 'my_') !== false)) {
+ // Throw it again
+ throw new InvalidArgumentException(sprintf('criteriaKey=%s has illegal prefix "my"', $criteriaKey));
+ } elseif (is_array($criteriaValue) || is_bool($criteriaValue) || is_object($criteriaValue) || is_resource($criteriaValue)) {
+ // Throw UAE
+ throw new UnexpectedValueException(sprintf('criteriaValue[]=%s is not accepted', gettype($criteriaValue)), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
+ }
+
+ // Convert dashes to underscore
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-CRITERIA: Invoking StringUtils::convertDashesToUnderscores(%s) ...', $criteriaKey));
+ $criteriaKey = StringUtils::convertDashesToUnderscores($criteriaKey);
// Add it
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($criteriaType) . '(' . $this->__toString() . ')-CRITERIA: criteriaKey=' . $criteriaKey . ',criteriaValue=' . $criteriaValue);
- $this->pushValueToGenericArrayElement('criteria', 'choice', 'entries', StringUtils::convertDashesToUnderscores($criteriaKey), (string) $criteriaValue);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-CRITERIA: Invoking this->pushValueToGenericArrayElement(criteria,%s,entries,%s,criteriaValue[]=%s) ...', Criteria::CRITERIA_TYPE_CHOICE, $criteriaKey, gettype($criteriaValue)));
+ $this->pushValueToGenericArrayElement('criteria', Criteria::CRITERIA_TYPE_CHOICE, 'entries', $criteriaKey, $criteriaValue);
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-CRITERIA: EXIT!');
}
/**
* @param $criteriaKey Criteria key
* @param $criteriaValue Criteria value
* @return void
+ * @throws InvalidArgumentException If a parameter is not valid
+ * @throws UnexpectedValueException If $criteriaValue has an unexpected type
*/
public final function addExcludeCriteria (string $criteriaKey, $criteriaValue) {
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-CRITERIA: criteriaKey=%s,criteriaValue[%s]=%s - CALLED!', $criteriaKey, gettype($criteriaValue), $criteriaValue));
+ if (empty($criteriaKey)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "criteriaKey" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif ((strpos($criteriaKey, 'my-') !== false) || (strpos($criteriaKey, 'my_') !== false)) {
+ // Throw it again
+ throw new InvalidArgumentException(sprintf('criteriaKey=%s has illegal prefix "my"', $criteriaKey));
+ } elseif (is_array($criteriaValue) || is_bool($criteriaValue) || is_object($criteriaValue) || is_resource($criteriaValue)) {
+ // Throw UAE
+ throw new UnexpectedValueException(sprintf('criteriaValue[]=%s is not accepted', gettype($criteriaValue)), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
+ }
+
// Add it with generic method
- $this->addCriteria($criteriaKey, $criteriaValue, 'exclude');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-CRITERIA: Invoking this->addCriteria(%s,criteriaValue[]=%s,%s) ...', $criteriaKey, gettype($criteriaValue), Criteria::CRITERIA_TYPE_EXCLUDE));
+ $this->addCriteria($criteriaKey, $criteriaValue, Criteria::CRITERIA_TYPE_EXCLUDE);
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-CRITERIA: EXIT!');
}
/**
* @param $configEntry Configuration entry
* @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
* @return void
+ * @throws InvalidArgumentException If a parameter is not valid
+ * @throws UnexpectedValueException If a parameter contains an unexpected/unsupported value
*/
- public final function addConfiguredCriteria (string $criteriaKey, string $configEntry, string $criteriaType = 'default') {
+ public final function addConfiguredCriteria (string $criteriaKey, string $configEntry, string $criteriaType = Criteria::CRITERIA_TYPE_DEFAULT) {
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-CRITERIA: criteriaKey=%s,configEntry=%s,criteriaType=%s - CALLED!', strtoupper($criteriaType), $criteriaKey, $configEntry, $criteriaType));
+ if (empty($criteriaKey)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "criteriaKey" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif ((strpos($criteriaKey, 'my-') !== false) || (strpos($criteriaKey, 'my_') !== false)) {
+ // Throw it again
+ throw new InvalidArgumentException(sprintf('criteriaKey=%s has illegal prefix "my"', $criteriaKey));
+ } elseif (empty($configEntry)) {
+ // Throw it again
+ throw new InvalidArgumentException('Parameter "configEntry" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($criteriaType)) {
+ // Throw it again
+ throw new InvalidArgumentException('Parameter "criteriaType" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (!in_array($criteriaType, self::$CRITERIA_TYPES)) {
+ // Throw it again
+ throw new UnexpectedValueException(sprintf('criteriaType=%s is not supported', $criteriaType), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
+ }
+
// Add the configuration entry as a criteria
$value = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry($configEntry);
+
+ // Invoke inner method
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-CRITERIA: Invoking this->addCriteria(%s,value[%s]=%s,%s) ...', strtoupper($criteriaType), $criteriaKey, gettype($value), $value, $criteriaType));
$this->addCriteria($criteriaKey, $value, $criteriaType);
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-CRITERIA: EXIT!', strtoupper($criteriaType)));
}
/**
* @param $criteriaKey The requested criteria key
* @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
* @return $value Whether the value of the critera or false
+ * @throws InvalidArgumentException If a parameter is not valid
+ * @throws UnexpectedValueException If a parameter contains an unexpected/unsupported value
*/
- public function getCriteriaElemnent (string $criteriaKey, string $criteriaType = 'default') {
- // Make sure no 'my-' or 'my_' passes this point
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($criteriaType) . '-CRITERIA: criteriaKey=' . $criteriaKey . ',criteriaType=' . $criteriaType . ' - CALLED!');
- assert((strpos($criteriaKey, 'my-') === false) && (strpos($criteriaKey, 'my_') === false));
+ public function getCriteriaElemnent (string $criteriaKey, string $criteriaType = Criteria::CRITERIA_TYPE_DEFAULT) {
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-CRITERIA: criteriaKey=%s,criteriaType=%s - CALLED!', strtoupper($criteriaType), $criteriaKey, $criteriaType));
+ if (empty($criteriaKey)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "criteriaKey" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif ((strpos($criteriaKey, 'my-') !== false) || (strpos($criteriaKey, 'my_') !== false)) {
+ // Throw it again
+ throw new InvalidArgumentException(sprintf('criteriaKey=%s has illegal prefix "my"', $criteriaKey));
+ } elseif (empty($criteriaType)) {
+ // Throw it again
+ throw new InvalidArgumentException('Parameter "criteriaType" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (!in_array($criteriaType, self::$CRITERIA_TYPES)) {
+ // Throw it again
+ throw new UnexpectedValueException(sprintf('criteriaType=%s is not supported', $criteriaType), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
+ }
// Convert dashes to underscore
$criteriaKey = StringUtils::convertDashesToUnderscores($criteriaKey);
// Default is not found
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($criteriaType) . '-CRITERIA: criteriaKey=' . $criteriaKey . ',criteria()=' . $this->countGenericArrayGroup('criteria', $criteriaType));
$value = false;
// Is the criteria there?
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('%s-CRITERIA: criteriaKey=%s,criteria()=%d', strtoupper($criteriaType), $criteriaKey, $this->countGenericArrayGroup('criteria', $criteriaType)));
if ($this->isKeySet($criteriaType, $criteriaKey)) {
// Then use it
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-CRITERIA: Invoking this->getGenericArrayElement(criteria,%s,entries,%s) ...', strtoupper($criteriaType), $criteriaType, $criteriaKey));
$value = $this->getGenericArrayElement('criteria', $criteriaType, 'entries', $criteriaKey);
}
// Return the value
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($criteriaType) . '-CRITERIA: value=' . $value . ' - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-CRITERIA: value[]=%s - EXIT!', strtoupper($criteriaType), gettype($value)));
return $value;
}
*
* @param $criteriaKey The requested criteria key
* @return $value Whether the value of the critera or false
+ * @throws InvalidArgumentException If a parameter is not valid
*/
public function getCriteriaChoiceElemnent (string $criteriaKey) {
- // Call inner method
- return $this->getCriteriaElemnent($criteriaKey, 'choice');
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-CRITERIA: criteriaKey=%s - CALLED!', $criteriaKey));
+ if (empty($criteriaKey)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "criteriaKey" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif ((strpos($criteriaKey, 'my-') !== false) || (strpos($criteriaKey, 'my_') !== false)) {
+ // Throw it again
+ throw new InvalidArgumentException(sprintf('criteriaKey=%s has illegal prefix "my"', $criteriaKey));
+ }
+
+ // Invoke inner method
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-CRITERIA: Invoking this->getCriteriaElemnent(%s,%s) ...', $criteriaKey, Criteria::CRITERIA_TYPE_CHOICE));
+ return $this->getCriteriaElemnent($criteriaKey, Criteria::CRITERIA_TYPE_CHOICE);
}
/**
*
* @param $criteriaKey The requested criteria key
* @return $value Whether the value of the critera or false
+ * @throws InvalidArgumentException If a parameter is not valid
*/
public function getCriteriaExcludeElemnent (string $criteriaKey) {
- // Call inner method
- return $this->getCriteriaElemnent($criteriaKey, 'exclude');
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-CRITERIA: criteriaKey=%s - CALLED!', $criteriaKey));
+ if (empty($criteriaKey)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "criteriaKey" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif ((strpos($criteriaKey, 'my-') !== false) || (strpos($criteriaKey, 'my_') !== false)) {
+ // Throw it again
+ throw new InvalidArgumentException(sprintf('criteriaKey=%s has illegal prefix "my"', $criteriaKey));
+ }
+
+ // Invoke inner method
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-CRITERIA: Invoking this->getCriteriaElemnent(%s,%s) ...', $criteriaKey, Criteria::CRITERIA_TYPE_EXCLUDE));
+ return $this->getCriteriaElemnent($criteriaKey, Criteria::CRITERIA_TYPE_EXCLUDE);
}
/**
* @param $entryArray Array with the entries to find
* @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
* @return $matches Whether the entry matches or not
+ * @throws InvalidArgumentException If a parameter is not valid
+ * @throws UnexpectedValueException If a parameter contains an unexpected/unsupported value
*/
- public function ifEntryMatches (array $entryArray, string $criteriaType = 'default') {
+ public function ifEntryMatches (array $entryArray, string $criteriaType = Criteria::CRITERIA_TYPE_DEFAULT) {
+ // Check parameters
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-CRITERIA: entryArray()=%d,criteriaType=%s - CALLED!', strtoupper($criteriaType), count($entryArray), $criteriaType));
+ if (count($entryArray) == 0) {
+ // Throw IAE
+ throw new InvalidArgumentException('entryArray cannot be an empty array');
+ } elseif (empty($criteriaType)) {
+ // Throw it again
+ throw new InvalidArgumentException('Parameter "criteriaType" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (!in_array($criteriaType, self::$CRITERIA_TYPES)) {
+ // Throw it again
+ throw new UnexpectedValueException(sprintf('criteriaType=%s is not supported', $criteriaType), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
+ }
+
// First nothing matches and nothing is counted
$matches = false;
$counted = 0;
// Walk through all entries
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('%s-CRITERIA: Walking over entryArray()=%d ...', strtoupper($criteriaType), count($entryArray)));
foreach ($entryArray as $key => $entry) {
// Make sure no 'my-' or 'my_' passes this point
- assert((strpos($key, 'my-') === false) && (strpos($key, 'my_') === false));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('%s-CRITERIA: key=%s,entry[%s]=%s', strtoupper($criteriaType), $key, gettype($entry), $entry));
+ if ((strpos($key, 'my-') !== false) || (strpos($key, 'my_') !== false)) {
+ // Throw it again
+ throw new InvalidArgumentException(sprintf('key=%s has illegal prefix "my"', $key));
+ }
// Convert dashes to underscore
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-CRITERIA: Invoking StringUtils::convertDashesToUnderscores(%s) ...', strtoupper($criteriaType), $key));
$key = StringUtils::convertDashesToUnderscores($key);
// Then walk through all search criteria
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('%s-CRITERIA: key=%s - AFTER!', strtoupper($criteriaType), $key));
foreach ($this->getGenericArrayKey('criteria', $criteriaType, 'entries') as $criteriaKey => $criteriaValue) {
// Make sure no 'my-' or 'my_' passes this point
- assert((strpos($criteriaKey, 'my-') === false) && (strpos($criteriaKey, 'my_') === false) && (!is_bool($criteriaValue)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('%s-CRITERIA: criteriaKey=%s,criteriaValue[%s]=%s', strtoupper($criteriaType), $criteriaKey, gettype($criteriaValue), $criteriaValue));
+ if ((strpos($criteriaKey, 'my-') !== false) || (strpos($criteriaKey, 'my_') !== false)) {
+ // Throw it again
+ throw new UnexpectedValueException(sprintf('criteriaKey=%s has illegal prefix "my"', $criteriaKey), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
+ }
// Convert dashes to underscore
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-CRITERIA: Invoking StringUtils::convertDashesToUnderscores(%s) ...', strtoupper($criteriaType), $criteriaKey));
$criteriaKey = StringUtils::convertDashesToUnderscores($criteriaKey);
// Is the element found and does it match?
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('%s-CRITERIA: key=%s,criteriaKey=%s', strtoupper($criteriaType), $key, $criteriaKey));
if (($key == $criteriaKey) && ($criteriaValue == $entry)) {
// Then count this one up
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('%s-CRITERIA: MATCHES!', strtoupper($criteriaType)));
$counted++;
}
}
}
// Now check if expected criteria counts match
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('%s-CRITERIA: counted=%d', strtoupper($criteriaType), $counted));
$matches = ($counted == $this->countGenericArrayGroup('criteria', $criteriaType));
// Return the result
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-CRITERIA: matches=%d - EXIT!', strtoupper($criteriaType), intval($matches)));
return $matches;
}
*
* @param $entryArray Array with the entries to find
* @return $matches Whether the entry matches or not
+ * @throws InvalidArgumentException If a parameter is not valid
*/
public function ifChoiceMatches (array $entryArray) {
- // Call inner method
- return $this->ifEntryMatches($entryArray, 'choice');
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-CRITERIA: entryArray()=%d - CALLED!', count($entryArray)));
+ if (count($entryArray) == 0) {
+ // Throw IAE
+ throw new InvalidArgumentException('entryArray cannot be an empty array');
+ }
+
+ // Invoke inner method
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-CRITERIA: Invoking this->ifEntryMatches(%d,%s) ...', count($entryArray), Criteria::CRITERIA_TYPE_CHOICE));
+ return $this->ifEntryMatches($entryArray, Criteria::CRITERIA_TYPE_CHOICE);
}
/**
*
* @param $entryArray Array with the entries to find
* @return $matches Whether the entry matches or not
+ * @throws InvalidArgumentException If a parameter is not valid
*/
public function ifExcludeMatches (array $entryArray) {
- // Call inner method
- return $this->ifEntryMatches($entryArray, 'exclude');
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-CRITERIA: entryArray()=%d - CALLED!', count($entryArray)));
+ if (count($entryArray) == 0) {
+ // Throw IAE
+ throw new InvalidArgumentException('entryArray cannot be an empty array');
+ }
+
+ // Invoke inner method
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-CRITERIA: Invoking this->ifEntryMatches(%d,%s) ...', count($entryArray), Criteria::CRITERIA_TYPE_EXCLUDE));
+ return $this->ifEntryMatches($entryArray, Criteria::CRITERIA_TYPE_EXCLUDE);
}
/**
* @param $onlyKeys Only use these keys for a cache key
* @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
* @return $cacheKey The key suitable for the cache system
+ * @throws InvalidArgumentException If a parameter is not valid
+ * @throws UnexpectedValueException If a parameter contains an unexpected/unsupported value
+ * @throws BadMethodCallException If this method is invoked before $criteriaType has been initialized
*/
- public function getCacheKey (array $onlyKeys = [], string $criteriaType = 'default') {
- // Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput($this->__toString() . ': criteriaType=' . $criteriaType . ',count()=' . $this->countGenericArray('criteria')));
-
- // Make sure the criteria is there
- assert($this->isValidGenericArrayGroup('criteria', $criteriaType));
+ public function getCacheKey (array $onlyKeys = [], string $criteriaType = Criteria::CRITERIA_TYPE_DEFAULT) {
+ // Check parameters
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-CRITERIA: onlyKeys()=%d,criteriaType=%s - CALLED!', strtoupper($criteriaType), count($onlyKeys), $criteriaType));
+ if (empty($criteriaType)) {
+ // Throw it again
+ throw new InvalidArgumentException('Parameter "criteriaType" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (!in_array($criteriaType, self::$CRITERIA_TYPES)) {
+ // Throw it again
+ throw new UnexpectedValueException(sprintf('criteriaType=%s is not supported', $criteriaType), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
+ } elseif (!$this->isValidGenericArrayGroup('criteria', $criteriaType)) {
+ // Not intialized yet
+ throw new BadMethodCallException(sprintf('Method cannot be invoked before criteriaType=%s is initialized!', $criteriaType), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
+ }
// Initialize the key
$cacheKey = '';
// Now walk through all criterias
foreach ($this->getGenericArrayKey('criteria', $criteriaType, 'entries') as $criteriaKey => $criteriaValue) {
// Make sure no 'my-' or 'my_' passes this point
- assert((strpos($criteriaKey, 'my-') === false) && (strpos($criteriaKey, 'my_') === false) && (!is_bool($criteriaValue)));
-
- // $criteriaValue cannot be an array
- assert(!is_array($criteriaValue));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('%s-CRITERIA: criteriaKey=%s,criteriaValue[%s]=%s', strtoupper($criteriaType), $criteriaKey, gettype($criteriaValue), $criteriaValue));
+ if ((strpos($criteriaKey, 'my-') !== false) || (strpos($criteriaKey, 'my_') !== false)) {
+ // Throw UAE
+ throw new UnexpectedValueException(sprintf('criteriaKey=%s has illegal prefix "my"', $criteriaKey), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
+ } elseif (is_array($criteriaValue) || is_bool($criteriaValue) || is_object($criteriaValue) || is_resource($criteriaValue)) {
+ // Throw it again
+ throw new UnexpectedValueException(sprintf('criteriaValue[]=%s is not supported', gettype($criteriaValue)), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
+ }
// Convert dashes to underscore
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-CRITERIA: Invoking StringUtils::convertDashesToUnderscores(%s) ...', strtoupper($criteriaType), $criteriaKey));
$criteriaKey = StringUtils::convertDashesToUnderscores($criteriaKey);
// Is the value in array or is $onlyKeys empty?
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('%s-CRITERIA: criteriaKey=%s', strtoupper($criteriaType), $criteriaKey));
if ((isset($onlyKeys[$criteriaKey])) || (count($onlyKeys) == 0)) {
// Add the value URL encoded to avoid any trouble with special characters
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('%s-CRITERIA: Adding criteriaKey=%s,criteriaValue[%s]=%s to cache key ...', strtoupper($criteriaType), $criteriaKey, gettype($criteriaValue), $criteriaValue));
$cacheKey .= sprintf('%s=%s;',
$criteriaKey,
urlencode($criteriaValue)
$cacheKey = substr($cacheKey, 0, -1);
// Is the instance SearchCriteria?
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('%s-CRITERIA: cacheKey=%s,this=%s', strtoupper($criteriaType), $cacheKey, $this->__toString()));
if ($this instanceof SearchCriteria) {
// Check if 'limit' and 'skip' are in
if (((isset($onlyKeys['limit'])) && (isset($onlyKeys['skip']))) || (count($onlyKeys) == 0)) {
// Add limit and skip values
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('%s-CRITERIA: Adding this->limit=%d,this->skip=%d to cache key ...', strtoupper($criteriaType), $this->getLimit(), $this->getSkip()));
$cacheKey .= sprintf(';%%limit%%=%s;%%skip%%=%s',
$this->getLimit(),
$this->getSkip()
}
// Return the cache key
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-CRITERIA: cacheKey=%s - EXIT!', strtoupper($criteriaType), $cacheKey));
return $cacheKey;
}
* @return $cacheKey The key suitable for the cache system
*/
public function getCacheKeyChoice (array $onlyKeys = []) {
- // Call inner method
- return $this->getCacheKey($onlyKeys, 'choice');
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-CRITERIA: onlyKeys()=%d - CALLED!', count($onlyKeys)));
+
+ // Invoke inner method
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-CRITERIA: Invoking this->getCacheKey(onlyKeys()=%d,%s) ...', count($onlyKeys),Criteria::CRITERIA_TYPE_CHOICE));
+ return $this->getCacheKey($onlyKeys, Criteria::CRITERIA_TYPE_CHOICE);
}
/**
* @return $cacheKey The key suitable for the cache system
*/
public function getCacheKeyExclude (array $onlyKeys = []) {
- // Call inner method
- return $this->getCacheKey($onlyKeys, 'exclude');
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-CRITERIA: onlyKeys()=%d - CALLED!', count($onlyKeys)));
+
+ // Invoke inner method
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-CRITERIA: Invoking this->getCacheKey(onlyKeys()=%d,%s) ...', count($onlyKeys),Criteria::CRITERIA_TYPE_EXCLUDE));
+ return $this->getCacheKey($onlyKeys, Criteria::CRITERIA_TYPE_EXCLUDE);
}
/**
* @return $count Count of all criteria entries
*/
public final function countChoice () {
- return $this->count('choice');
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-CRITERIA: CALLED!');
+ return $this->count(Criteria::CRITERIA_TYPE_CHOICE);
}
/**
* @return $count Count of all criteria entries
*/
public final function countExclude () {
- return $this->count('exclude');
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-CRITERIA: CALLED!');
+ return $this->count(Criteria::CRITERIA_TYPE_EXCLUDE);
}
}
use Org\Mxchange\CoreFramework\Criteria\BaseCriteria;
use Org\Mxchange\CoreFramework\Criteria\Local\LocalSearchCriteria;
use Org\Mxchange\CoreFramework\Criteria\Storing\StoreableCriteria;
-use Org\Mxchange\CoreFramework\EntryPoint\ApplicationEntryPoint;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
// Import SPL stuff
+use \BadMethodCallException;
use \InvalidArgumentException;
/**
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*/
public static final function createDataSetCriteria (string $tableName) {
// Validate parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('DATA-SET-CRITERIA: tableName=%s - CALLED!', $tableName));
if (empty($tableName)) {
// Throw IAE
- throw new InvalidArgumentException('Parameter "tableName" is empty');
+ throw new InvalidArgumentException('Parameter "tableName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
}
// Get a new instance
$criteriaInstance->setTableName($tableName);
// Return the instance
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('DATA-SET-CRITERIA: criteriaInstance=%s - EXIT!', $criteriaInstance->__toString()));
return $criteriaInstance;
}
* Getter for unique key value
*
* @return $uniqueValue Value of the unique key
+ * @throws BadMethodCallException If no primary and no unique key was found
*/
public final function getUniqueValue () {
// Get primary key(s) first
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('DATA-SET-CRITERIA: CALLED!');
$primaryKey = trim($this->getCriteriaElemnent($this->getPrimaryKey()));
$primaryKeys = $this->getPrimaryKeys();
- // Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATA-SET-CRITERIA: tableName=' . $this->getTableName() . ',primaryKey=' . $primaryKey . ',primaryKeys()=' . count($primaryKeys));
-
/*
* If this is not set, this could mean a badly written frontend as
* tables should always have a primary key.
*/
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('DATA-SET-CRITERIA: this->tableName=%s,primaryKey=%s,primaryKeys()=%d', $this->getTableName(), $primaryKey, count($primaryKeys)));
if (count($primaryKeys) > 0) {
/*
* Init return value, this can be put all together without any
$return = '';
// Combination set, so get all
- foreach ($primaryKeys as $primaryKey) {
+ foreach ($primaryKeys as $primaryKeyPart) {
// Add it
- $return .= trim($this->getCriteriaElemnent($primaryKey));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('DATA-SET-CRITERIA: primaryKeyPart=%s', $primaryKeyPart));
+ $return .= trim($this->getCriteriaElemnent($primaryKeyPart));
}
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATA-SET-CRITERIA: tableName=' . $this->getTableName() . ',return=' . $return . ' - EXIT!');
// Return it
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('DATA-SET-CRITERIA: return=%s - EXIT!', $return));
return $return;
} elseif (!empty($primaryKey)) {
// Return primary key
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('DATA-SET-CRITERIA: primaryKey=%s - EXIT!', $primaryKey));
return $primaryKey;
} else {
- // @TODO Issue a warning
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATA-SET-CRITERIA: Primary key not set for table ' . $this->getTableName() . ', please fix your table. Falling back to unique key ...');
+ // Issue a warning
+ self::createDebugInstance(__CLASS__, __LINE__)->warningMessage('DATA-SET-CRITERIA: Primary key not set for table ' . $this->getTableName() . ', please fix your table. Falling back to unique key ...');
// Get unique key
$uniqueKey = trim($this->getCriteriaElemnent($this->getUniqueKey()));
- // Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATA-SET-CRITERIA: tableName=' . $this->getTableName() . ',uniqueKey=' . $uniqueKey);
-
// Is it empty, too?
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('DATA-SET-CRITERIA: uniqueKey=%s', $uniqueKey));
if (empty($uniqueKey)) {
// Bad news, nothing is "unique" by design for this table
- ApplicationEntryPoint::exitApplication('Table ' . $this->getTableName() . ' has both no primary and unique key, but ' . __METHOD__ . ' was called. Please fix your table.');
- } else {
- // Return unique key
- return $uniqueKey;
+ throw new BadMethodCallException(sprintf('Table %s has both no primary and unique key, but %s was called. Please fix your table.', $this->getTableName(), __METHOD__), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
}
+
+ // Return unique key
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('DATA-SET-CRITERIA: uniqueKey=%s - EXIT!', $uniqueKey));
+ return $uniqueKey;
}
}
*/
public final function getPrimaryKey () {
// Get primary key by default
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('DATA-SET-CRITERIA: CALLED!');
$primaryKey = $this->primaryKey;
+ // Is it still empty?
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('DATA-SET-CRITERIA: primaryKey=%s', $primaryKey));
if (empty($primaryKey)) {
// Get uniqueKey
$primaryKey = $this->getUniqueKey();
}
// Return it
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('DATA-SET-CRITERIA: primaryKey=%s - EXIT!', $primaryKey));
return $primaryKey;
}
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
use Org\Mxchange\CoreFramework\Criteria\BaseCriteria;
use Org\Mxchange\CoreFramework\Criteria\Local\LocalSearchCriteria;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
// Import SPL stuff
use \InvalidArgumentException;
+use \UnexpectedValueException;
/**
* Search criteria for e.g. searching in databases. Do not use this class if
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*/
public static final function createSearchCriteria () {
// Get a new instance
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('SEARCH-CRITERIA: CALLED!');
$criteriaInstance = new SearchCriteria();
// Return this instance
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('SEARCH-CRITERIA: criteriaInstance=%s - EXIT!', $criteriaInstance->__toString()));
return $criteriaInstance;
}
/**
* "Setter" for limit from a configuration entry
*
- * @param $configEntry The configuration entry which hold a number as limit
+ * @param $configKey The configuration entry which hold a number as limit
* @return void
+ * @throws InvalidArgumentException If a paramter has an invalid value
*/
- public final function setConfiguredLimit (string $configEntry) {
- // Get the limit from config entry and set it
- $limit = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry($configEntry);
+ public final function setConfiguredLimit (string $configKey) {
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('SEARCH-CRITERIA: configKey=%s - CALLED!', $configKey));
+ if (empty($configKey)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "configKey" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
+ // Get the limit from config entry
+ $limit = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry($configKey);
+
+ // And set it
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('SEARCH-CRITERIA: limit=%d', $limit));
$this->setLimit($limit);
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('SEARCH-CRITERIA: EXIT!');
}
/**
* @param $separator Separator for "exploding" $value (default: ',')
* @return $isMatching Whether the key/value is matching or excluded
* @throws InvalidArgumentException If a parameter is invalid
+ * @throws UnexpectedValueException If $searchChoice is not an array
*/
public function isCriteriaMatching (string $key, $value, string $separator = ',') {
// $key/$value cannot be array/NULL/bool, value can be NULL but then NULL must be loocked for
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SEARCH-CRITERIA: key=%s,value[]=%s,separator=%s - CALLED!', $key, gettype($value), $separator));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('SEARCH-CRITERIA: key=%s,value[]=%s,separator=%s - CALLED!', $key, gettype($value), $separator));
if (empty($key)) {
// Throw IAE
- throw new InvalidArgumentException('Parameter "key" is empty');
- } elseif (is_array($value) || is_bool($value) || is_bool($value) || is_object($value) || is_resource($value)) {
+ throw new InvalidArgumentException('Parameter "key" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (is_array($value) || is_bool($value) || is_object($value) || is_resource($value)) {
// Throw it again
throw new InvalidArgumentException(sprintf('value[]=%s is not supported/valid', gettype($value)));
} elseif (empty($separator)) {
// Throw IAE
- throw new InvalidArgumentException('Parameter "separator" is empty');
+ throw new InvalidArgumentException('Parameter "separator" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
}
// "Explode" value
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('SEARCH-CRITERIA: Invoking explode("%s",value[]=%s) ...', $separator, gettype($value)));
$valueArray = explode($separator, $value);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('SEARCH-CRITERIA: valueArray()=%d', count($valueArray)));
// Get 'default' search value
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('SEARCH-CRITERIA: Invoking this->getCriteriaElemnent(%s) ...', $key));
$searchDefault = $this->getCriteriaElemnent($key);
// 'default' check
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SEARCH-CRITERIA: getCriteriaElement(' . $key . ')[' . gettype($searchDefault) . ']=' . $searchDefault);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('SEARCH-CRITERIA: searchDefault[%s]=%s', gettype($searchDefault), $searchDefault));
$isMatching = (
(
(
);
// Get 'choice' search value (can be NULL or $separator-separated string)
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SEARCH-CRITERIA: getCriteriaElement(' . $key . ')[' . gettype($searchDefault) . ']=' . $searchDefault . ',isMatching=' . intval($isMatching));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('SEARCH-CRITERIA: isMatching=%d', intval($isMatching)));
$searchChoice = $this->getCriteriaChoiceElemnent($key);
- // May be false or array
- assert(($searchChoice === false) || (is_array($searchChoice)));
+ // Is an array returned?
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('SEARCH-CRITERIA: searchChoice[]=%s', gettype($searchChoice)));
+ if (!is_array($searchChoice) && !is_bool($searchChoice)) {
+ // Should not happen
+ throw new UnexpectedValueException(sprintf('searchChoice[]=%s is unexpected', gettype($searchChoice)), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
+ }
// 'choice' check
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SEARCH-CRITERIA: getCriteriaChoiceElement(' . $key . ')[' . gettype($searchChoice) . ']=' . print_r($searchChoice, true));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('SEARCH-CRITERIA: searchChoice[]=%s', gettype($searchChoice)));
if ((is_array($searchChoice)) && (count($valueArray) == 1)) {
// $value is a single-search value, so use in_[]
$isMatching = ((($isMatching === true) || (($searchDefault === false) && (!is_null($value)))) && (in_array($value, $searchChoice)));
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SEARCH-CRITERIA: getCriteriaChoiceElement(' . $key . ')[]=' . gettype($searchChoice) . ',value[' . gettype($value) . ']=' . $value . ',isMatching=' . intval($isMatching) . ' - SINGLE-MATCH');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('SEARCH-CRITERIA: isMatching=%d - SINGLE-MATCH', intval($isMatching)));
} elseif ((is_array($searchChoice)) && (count($valueArray) > 1)) {
- // Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SEARCH-CRITERIA: getCriteriaChoiceElement(' . $key . ')[]=' . gettype($searchChoice) . ',value[]=' . count($valueArray) . ',isMatching=' . intval($isMatching));
-
// $value is choice-search value, so check all entries
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('SEARCH-CRITERIA: searchChoice()=%d,valueArray()=%d - MULTI-MATCH', count($searchChoice), count($valueArray)));
$isMatching = (($isMatching === true) || (($searchDefault === false) && (!is_null($value))));
- $idx = 0;
- foreach ($valueArray as $idx => $match) {
- // Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SEARCH-CRITERIA: match=' . $match . ',count(searchChoice)=' . count($searchChoice));
+ // Loop through all values
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('SEARCH-CRITERIA: isMatching=%d - BEFORE!', intval($isMatching)));
+ foreach ($valueArray as $idx => $match) {
// Is it found? (one is okay)
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('SEARCH-CRITERIA: idx=%d,match=%s', $idx, $match));
$isMatching = (($isMatching === true) && (in_array($match, $searchChoice)));
- // Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SEARCH-CRITERIA: match=' . $match . ',isMatching=' . intval($isMatching));
+ // No longer matching?
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('SEARCH-CRITERIA: isMatching=%d - LOOP!', intval($isMatching)));
+ if (!$isMatching) {
+ // Skip further iterations
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('SEARCH-CRITERIA: BREAK!');
+ break;
+ }
}
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SEARCH-CRITERIA: getCriteriaChoiceElement(' . $key . ')[]=' . gettype($searchChoice) . ',value[]=' . count($valueArray) . ',idx=' . $idx . ',isMatching=' . intval($isMatching) . ' - CHOICE-MATCH');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('SEARCH-CRITERIA: isMatching=%d - AFTER!', intval($isMatching)));
} else {
// Choice-match is false
- // Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SEARCH-CRITERIA: getCriteriaChoiceElement(' . $key . ')[]=' . gettype($searchChoice) . ',value[' . gettype($value) . ']=' . $value . ',isMatching=' . intval($isMatching) . ' - false-MATCH');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('SEARCH-CRITERIA: key=%s[],searchChoice[]=%s,value[%s]=%s,isMatching=%d - FALSE-MATCH', $key, gettype($searchChoice), gettype($value), $value, intval($isMatching)));
}
// Get 'exclude' search value
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SEARCH-CRITERIA: getCriteriaChoiceElement(' . $key . ')[]=' . gettype($searchChoice) . ',isMatching=' . intval($isMatching));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('SEARCH-CRITERIA: Invoking this->getCriteriaExcludeElemnent(%s) ...', $key));
$searchExclude = $this->getCriteriaExcludeElemnent($key);
// 'exclude' check
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SEARCH-CRITERIA: getCriteriaExcludeElement(' . $key . ')[' . gettype($searchExclude) . ']=' . $searchExclude);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('SEARCH-CRITERIA: searchExclude[%s]=%s', gettype($searchExclude), $searchExclude));
$isMatching = (
(
(
);
// Return result
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SEARCH-CRITERIA: key=' . $key . ',value[' . gettype($value) . ']=' . $value . ',isMatching=' . intval($isMatching) . ' - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('SEARCH-CRITERIA: isMatching=%d - EXIT!', intval($isMatching)));
return $isMatching;
}
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*/
public static final function createUpdateCriteria () {
// Get a new instance
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('UPDATE-CRITERIA: CALLED!');
$criteriaInstance = new UpdateCriteria();
// Return this instance
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('SEARCH-CRITERIA: criteriaInstance=%s - EXIT!', $criteriaInstance->__toString()));
return $criteriaInstance;
}
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*/
public static final function createCryptoHelper () {
// Get a new instance
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CRYPTO-HELPER: CALLED!');
$cryptoInstance = new CryptoHelper();
// Initialize the hasher
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CRYPTO-HELPER: Invoking cryptoInstance->initHasher() ...');
$cryptoInstance->initHasher();
// Attach a crypto stream
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CRYPTO-HELPER: Invoking cryptoInstance->attachCryptoStream() ...');
$cryptoInstance->attachCryptoStream();
// Return the instance
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CRYPTO-HELPER: cryptoInstance=%s - EXIT!', $cryptoInstance->__toString()));
return $cryptoInstance;
}
*/
public static final function getSelfInstance () {
// Is no instance there?
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CRYPTO-HELPER: self::selfInstance[]=%s - CALLED!', gettype(self::$selfInstance)));
if (is_null(self::$selfInstance)) {
// Then get a new one
self::$selfInstance = self::createCryptoHelper();
}
// Return the instance
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CRYPTO-HELPER: self::selfInstance=%s - EXIT!', self::$selfInstance->__toString()));
return self::$selfInstance;
}
*/
protected function attachCryptoStream () {
// @TODO Maybe rewrite this with DirectoryIterator, similar to Compressor thing?
- // Do we have openssl/mcrypt loaded?
- if ($this->isPhpExtensionLoaded('mcrypt')) {
+ // Do we have openssl loaded?
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CRYPTO-HELPER: CALLED!');
+ if ($this->isPhpExtensionLoaded('openssl')) {
// Then use it
- $this->cryptoStreamInstance = ObjectFactory::createObjectByConfiguredName('crypto_mcrypt_stream_class', array($this->getRngInstance()));
- } elseif ($this->isPhpExtensionLoaded('openssl')) {
- // Then use it
- $this->cryptoStreamInstance = ObjectFactory::createObjectByConfiguredName('crypto_openssl_stream_class', array($this->getRngInstance()));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('CRYPTO-HELPER: Attaching openssl crypto stream ...');
+ $this->cryptoStreamInstance = ObjectFactory::createObjectByConfiguredName('crypto_openssl_stream_class', [$this->getRngInstance()]);
} else {
// If nothing works ...
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('CRYPTO-HELPER: Attaching NULL crypto stream ...');
$this->cryptoStreamInstance = ObjectFactory::createObjectByConfiguredName('crypto_null_stream_class');
}
+
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CRYPTO-HELPER: EXIT!');
}
/**
* @see DatabaseBackend - An interface for database backends
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
use Org\Mxchange\CoreFramework\Database\Backend\BaseDatabaseBackend;
use Org\Mxchange\CoreFramework\Database\Backend\DatabaseBackend;
use Org\Mxchange\CoreFramework\Database\Sql\SqlException;
+use Org\Mxchange\CoreFramework\EntryPoint\ApplicationEntryPoint;
use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
use Org\Mxchange\CoreFramework\Filesystem\FileNotFoundException;
use Org\Mxchange\CoreFramework\Generic\FrameworkException;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Result\Database\BaseDatabaseResult;
use Org\Mxchange\CoreFramework\Traits\Compressor\Channel\CompressorChannelTrait;
use Org\Mxchange\CoreFramework\Traits\Handler\Io\IoHandlerTrait;
// Import SPL stuff
+use \BadMethodCallException;
use \InvalidArgumentException;
use \SplFileInfo;
-use \UnexpectedValueException;
/**
* Database backend class for storing objects in locally created files.
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*/
public static final function createCachedLocalFileDatabase () {
// Get an instance
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CACHED-LOCAL-FILE-DATABASE: CALLED!');
$databaseInstance = new CachedLocalFileDatabase();
// Set the compressor channel
$databaseInstance->connectToDatabase();
// Return database instance
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-LOCAL-FILE-DATABASE: databaseInstance=%s - EXIT!', $databaseInstance->__toString()));
return $databaseInstance;
}
*/
private function getDataArrayFromFile (SplFileInfo $infoInstance) {
// Init compressed data
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CACHED-LFDB: Reading elements from database file ' . $infoInstance . ' ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-LOCAL-FILE-DATABASE: infoInstance=%s - CALLED!', $infoInstance->__toString()));
$compressedData = $this->getFileIoInstance()->loadFileContents($infoInstance);
- $compressedData = $compressedData['data'];
+
+ // Is it valid?
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CACHED-LOCAL-FILE-DATABASE: compressedData[]=%s', gettype($compressedData)));
+ //* DEBUG-DIE: */ die(sprintf('[%s:%d]: compressedData=%s', __METHOD__, __LINE__, print_r($compressedData, TRUE)));
+ if (!isset($compressedData['data'])) {
+ // Important element not found
+ ApplicationEntryPoint::exitApplication(sprintf('compressedData()=%d has no element "data"', count($compressedData)), FrameworkInterface::EXCEPTION_OUT_OF_BOUNDS);
+ }
// Decompress it
- $serializedData = $this->getCompressorChannelInstance()->getCompressor()->decompressStream($compressedData);
+ $serializedData = $this->getCompressorChannelInstance()->getCompressor()->decompressStream($compressedData['data']);
// Unserialize it
$dataArray = json_decode($serializedData, true);
// Finally return it
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CACHED-LFDB: Read ' . count($dataArray) . ' elements from database file ' . $infoInstance . '.');
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CACHED-LFDB: dataArray=' . print_r($dataArray, true));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-LOCAL-FILE-DATABASE: dataArray()=%d - EXIT!', count($dataArray)));
return $dataArray;
}
*/
private function writeDataArrayToFqfn (SplFileInfo $infoInstance, array $dataArray) {
// Serialize and compress it
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CACHED-LFDB: Flushing ' . count($dataArray) . ' elements to database file ' . $infoInstance . ' ...');
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CACHED-LFDB: dataArray=' . print_r($dataArray, true));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CACHED-LOCAL-FILE-DATABASE: Flushing ' . count($dataArray) . ' elements to database file ' . $infoInstance . ' ...');
$compressedData = $this->getCompressorChannelInstance()->getCompressor()->compressStream(json_encode($dataArray));
// Write this data BASE64 encoded to the file
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CACHED-LFDB: Writing ' . strlen($compressedData) . ' bytes ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CACHED-LOCAL-FILE-DATABASE: Writing ' . strlen($compressedData) . ' bytes ...');
$this->getFileIoInstance()->saveStreamToFile($infoInstance, $compressedData, $this);
- // Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CACHED-LFDB: Flushing ' . count($dataArray) . ' elements to database file completed.');
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CACHED-LOCAL-FILE-DATABASE: Flushing ' . count($dataArray) . ' elements to database file completed.');
}
/**
*/
private function getContentsFromTableInfoFile (StoreableCriteria $dataSetInstance) {
// Default content is no data
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-LOCAL-FILE-DATABASE: dataSetInstance=%s - CALLED!', $dataSetInstance->__toString()));
$infoArray = [];
// Create FQFN for getting the table information file
$infoInstance = $this->generateFileFromDataSet($dataSetInstance, 'info');
// Get the file contents
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CACHED-LOCAL-FILE-DATABASE: infoInstance=%s', $infoInstance->__toString()));
try {
$infoArray = $this->getDataArrayFromFile($infoInstance);
} catch (FileNotFoundException $e) {
}
// ... and return it
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-LOCAL-FILE-DATABASE: infoArray()=%d - EXIT!', count($infoArray)));
return $infoArray;
}
*/
private function generateFileFromDataSet (Criteria $dataSetInstance, string $rowName) {
// Instanciate new file object
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-LOCAL-FILE-DATABASE: dataSetInstance=%s,rowName=%s - CALLED!', $dataSetInstance->__toString(), $rowName));
$infoInstance = new SplFileInfo(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('local_database_path') . $dataSetInstance->getTableName() . DIRECTORY_SEPARATOR . $rowName . '.' . $this->getFileExtension());
// Return it
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-LOCAL-FILE-DATABASE: infoInstance=%s - EXIT!', $infoInstance->__toString()));
return $infoInstance;
}
* @return void
*/
private function createTableInfoFile (StoreableCriteria $dataSetInstance) {
- // Create FQFN for creating the table information file
- $infoInstance = $this->generateFileFromDataSet($dataSetInstance, 'info');
+ // Get table name
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-LOCAL-FILE-DATABASE: dataSetInstance=%s - CALLED!', $dataSetInstance->__toString()));
+ $tableName = $dataSetInstance->getTableName();
// Get the data out from dataset in a local array
- $this->tableInfo[$dataSetInstance->getTableName()] = array(
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CACHED-LOCAL-FILE-DATABASE: tableName=%', $tableName));
+ $this->tableInfo[$tableName] = [
'primary' => $dataSetInstance->getPrimaryKey(),
'created' => time(),
- 'last_updated' => time()
- );
+ 'last_updated' => time(),
+ ];
+
+ // Get info instance
+ $infoInstance = $this->generateFileFromDataSet($dataSetInstance, 'info');
// Write the data to the file
- $this->writeDataArrayToFqfn($infoInstance, $this->tableInfo[$dataSetInstance->getTableName()]);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-LOCAL-FILE-DATABASE: Invoking this->writeDataArrayToFqfn(%s,this->tableInfo[%s]()=%d) ...', $infoInstance->__toString(), $tableName, count($this->tableInfo[$tableName])));
+ $this->writeDataArrayToFqfn($infoInstance, $this->tableInfo[$tableName]);
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CACHED-LOCAL-FILE-DATABASE: EXIT!');
}
/**
*/
private function updateTableInfoFile (StoreableCriteria $dataSetInstance) {
// Get table name from criteria
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-LOCAL-FILE-DATABASE: dataSetInstance=%s - CALLED!', $dataSetInstance->__toString()));
$tableName = $dataSetInstance->getTableName();
// Create FQFN for creating the table information file
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CACHED-LOCAL-FILE-DATABASE: tableName=%', $tableName));
$infoInstance = $this->generateFileFromDataSet($dataSetInstance, 'info');
// Get the data out from dataset in a local array
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CACHED-LOCAL-FILE-DATABASE: infoInstance=%s', $infoInstance->__toString()));
$this->tableInfo[$tableName]['primary'] = $dataSetInstance->getPrimaryKey();
$this->tableInfo[$tableName]['last_updated'] = time();
// Write the data to the file
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-LOCAL-FILE-DATABASE: Invoking this->writeDataArrayToFqfn(%s,this->tableInfo[%s]()=%d) ...', $infoInstance->__toString(), $tableName, count($this->tableInfo[$tableName])));
$this->writeDataArrayToFqfn($infoInstance, $this->tableInfo[$tableName]);
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CACHED-LOCAL-FILE-DATABASE: EXIT!');
}
/**
*/
private function updatePrimaryKey (StoreableCriteria $dataSetInstance) {
// Get table name from criteria
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CACHED-LFDB: dataSetInstance=%s - CALLED!', $dataSetInstance->__toString()));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-LOCAL-FILE-DATABASE: dataSetInstance=%s - CALLED!', $dataSetInstance->__toString()));
$tableName = $dataSetInstance->getTableName();
// Get the information array from lower method
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CACHED-LFDB: tableName=%s', $tableName));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CACHED-LOCAL-FILE-DATABASE: tableName=%s', $tableName));
$infoArray = $this->getContentsFromTableInfoFile($dataSetInstance);
// Is the primary key there?
- //* PRINTR-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CACHED-LFDB: tableInfo=' . print_r($this->tableInfo, true));
+ //* PRINTR-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CACHED-LOCAL-FILE-DATABASE: tableInfo=' . print_r($this->tableInfo, true));
if (!isset($this->tableInfo[$tableName]['primary'])) {
// Then create the info file
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CACHED-LFDB: Creating info table for tableName=%s ...', $tableName));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CACHED-LOCAL-FILE-DATABASE: Creating info table for tableName=%s ...', $tableName));
$this->createTableInfoFile($dataSetInstance);
- } elseif ((FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('db_update_primary_forced') == 'Y') && ($dataSetInstance->getPrimaryKey() != $this->tableInfo[$tableName]['primary'])) {
+ } elseif (FrameworkBootstrap::getConfigurationInstance()->isEnabled('db_update_primary_forced') && $dataSetInstance->getPrimaryKey() != $this->tableInfo[$tableName]['primary']) {
// Set the array element
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CACHED-LFDB: Setting primaryKey=%s for tableName=%s ...', $dataSetInstance->getPrimaryKey(), $tableName));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CACHED-LOCAL-FILE-DATABASE: Setting primaryKey=%s for tableName=%s ...', $dataSetInstance->getPrimaryKey(), $tableName));
$this->tableInfo[$tableName]['primary'] = $dataSetInstance->getPrimaryKey();
// Update the entry
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CACHED-LFDB: Updating info table for tableName=%s ...', $tableName));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CACHED-LOCAL-FILE-DATABASE: Updating info table for tableName=%s ...', $tableName));
$this->updateTableInfoFile($dataSetInstance);
}
// Trace message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CACHED-LFDB: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CACHED-LOCAL-FILE-DATABASE: EXIT!');
}
/**
* @todo Do some checks on the database directory and files here
*/
public function connectToDatabase () {
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CACHED-LOCAL-FILE-DATABASE: CALLED!');
}
/**
*/
public function querySelect (string $tableName, LocalSearchCriteria $searchInstance) {
// Validate parameter
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CACHED-LFDB: tableName=%s,searchInstance=%s - CALLED!', $tableName, $searchInstance->__toString()));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-LOCAL-FILE-DATABASE: tableName=%s,searchInstance=%s - CALLED!', $tableName, $searchInstance->__toString()));
if (empty($tableName)) {
// Throw IAE
- throw new InvalidArgumentException('Parameter "tableName" is empty');
+ throw new InvalidArgumentException('Parameter "tableName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif (!isset($this->pathNames[$tableName])) {
// "Cache" is not present, so create and assign it
$this->pathNames[$tableName] = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('local_database_path') . $tableName . DIRECTORY_SEPARATOR;
*/
try {
// Get a directory pointer instance
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CACHED-LFDB: Getting directory_class for this->pathNames[%s]=%s ...', $tableName, $this->pathNames[$tableName]));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CACHED-LOCAL-FILE-DATABASE: Getting directory_class for this->pathNames[%s]=%s ...', $tableName, $this->pathNames[$tableName]));
$directoryInstance = ObjectFactory::createObjectByConfiguredName('directory_class', [$this->pathNames[$tableName]]);
// Initialize the result data, this need to be rewritten e.g. if a local file cannot be read
$resultData = [
- BaseDatabaseResult::RESULT_NAME_STATUS => self::RESULT_OKAY,
- BaseDatabaseResult::RESULT_NAME_ROWS => []
+ BaseDatabaseResult::RESULT_NAME_STATUS => self::RESULT_OKAY,
+ BaseDatabaseResult::RESULT_NAME_ROWS => [],
+ BaseDatabaseResult::RESULT_NAME_EXCEPTION => NULL,
];
// Initialize limit/skip
// Read the directory with some exceptions
while (($fileInfoInstance = $directoryInstance->readDirectoryExcept(['.gitkeep', 'info.' . $this->getFileExtension()])) && (($limitFound < $searchInstance->getLimit()) || ($searchInstance->getLimit() == 0))) {
// Does the extension match?
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CACHED-LFDB: fileInfoInstance->extension=%s,this->fileExtension=%s', $fileInfoInstance->getExtension(), $this->getFileExtension()));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CACHED-LOCAL-FILE-DATABASE: fileInfoInstance->extension=%s,this->fileExtension=%s', $fileInfoInstance->getExtension(), $this->getFileExtension()));
if ($fileInfoInstance->getExtension() !== $this->getFileExtension()) {
// Skip this file!
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CACHED-LFDB: Skipping fileInfoInstance->filename=%s ...', $fileInfoInstance->getFilename()));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CACHED-LOCAL-FILE-DATABASE: Skipping fileInfoInstance->filename=%s ...', $fileInfoInstance->getFilename()));
$directoryInstance->getDirectoryIteratorInstance()->next();
continue;
}
$dataArray = $this->getDataArrayFromFile($fileInfoInstance);
// Is this an array?
- //* PRINTR-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CACHED-LFDB: fileInfoInstance.pathname=' . $fileInfoInstance->getPathname() . ',dataArray='.print_r($dataArray, true));
+ //* PRINTR-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('CACHED-LOCAL-FILE-DATABASE: fileInfoInstance->pathname=' . $fileInfoInstance->getPathname() . ',dataArray='.print_r($dataArray, true));
if (is_array($dataArray)) {
// Default is nothing found
$isFound = true;
// Search in the criteria with FMFW (First Matches, First Wins)
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CACHED-LFDB: data[]=%d', count($dataArray)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CACHED-LOCAL-FILE-DATABASE: data[]=%d', count($dataArray)));
foreach ($dataArray as $key => $value) {
// Found one entry?
$isFound = ($isFound && $searchInstance->isCriteriaMatching($key, $value));
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CACHED-LFDB: key=%s,value[%s]=%s,isFound=%s', $key, gettype($value), $value, intval($isFound)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CACHED-LOCAL-FILE-DATABASE: key=%s,value[%s]=%s,isFound=%s', $key, gettype($value), $value, intval($isFound)));
}
// Is all found?
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CACHED-LFDB: isFound=%d,limitFound=%d,limit=%d', intval($isFound), $limitFound, $searchInstance->getLimit()));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CACHED-LOCAL-FILE-DATABASE: isFound=%d,limitFound=%d,limit=%d', intval($isFound), $limitFound, $searchInstance->getLimit()));
if ($isFound === true) {
// Shall we skip this entry?
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CACHED-LFDB: searchInstance->skip=%d,skipFound=%d', $searchInstance->getSkip(), $skipFound));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CACHED-LOCAL-FILE-DATABASE: searchInstance->skip=%d,skipFound=%d', $searchInstance->getSkip(), $skipFound));
if ($searchInstance->getSkip() > 0 && $skipFound < $searchInstance->getSkip()) {
// Skip this entry
$skipFound++;
}
// Set id number
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CACHED-LFDB: Setting dataArray[%s]=%d', $this->getIndexKey(), $idx));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CACHED-LOCAL-FILE-DATABASE: Setting dataArray[%s]=%d', $this->getIndexKey(), $idx));
$dataArray[$this->getIndexKey()] = $idx;
// Entry found!
array_push($resultData[BaseDatabaseResult::RESULT_NAME_ROWS], $dataArray);
// Count found entries up
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CACHED-LFDB: resultData[%s]()=%d', BaseDatabaseResult::RESULT_NAME_ROWS, count($resultData[BaseDatabaseResult::RESULT_NAME_ROWS])));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CACHED-LOCAL-FILE-DATABASE: resultData[%s]()=%d', BaseDatabaseResult::RESULT_NAME_ROWS, count($resultData[BaseDatabaseResult::RESULT_NAME_ROWS])));
$limitFound++;
}
} else {
}
// Return the gathered result
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-LOCAL-FILE-DATABASE: resultData()=%d - EXIT!', count($resultData)));
return $resultData;
}
*/
public function queryInsertDataSet (StoreableCriteria $dataSetInstance) {
// Try to save the request away
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CACHED-LFDB: dataSetInstance=%s - CALLED!', $dataSetInstance->__toString()));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-LOCAL-FILE-DATABASE: dataSetInstance=%s - CALLED!', $dataSetInstance->__toString()));
try {
// Create full path name
$infoInstance = $this->generateFileFromDataSet($dataSetInstance, md5($dataSetInstance->getUniqueValue()));
}
// Trace message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CACHED-LFDB: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CACHED-LOCAL-FILE-DATABASE: EXIT!');
}
/**
*
* @param $dataSetInstance An instance of a StorableCriteria class
* @return void
- * @throws UnexpectedValueException If $tableName is empty
+ * @throws InvalidArgumentException If $tableName is empty
* @throws SqlException If an SQL error occurs
*/
public function queryUpdateDataSet (StoreableCriteria $dataSetInstance) {
// Get table name
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-LOCAL-FILE-DATABASE: dataSetInstance=%s - CALLED!', $dataSetInstance->__toString()));
$tableName = $dataSetInstance->getTableName();
// Is "cache" there?
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CACHED-LOCAL-FILE-DATABASE: tableName=%s', $tableName));
if (empty($tableName)) {
// Should never be an empty string
- throw new UnexpectedValueException('Class field dataSetInstance->tableName is empty');
+ throw new InvalidArgumentException('Class field dataSetInstance->tableName is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif (!isset($this->pathNames[$tableName])) {
// "Cache" is not present, so create and assign it
$this->pathNames[$tableName] = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('local_database_path') . $tableName . DIRECTORY_SEPARATOR;
$searchArray = $dataSetInstance->getCriteriaArray();
// Get search criteria
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CACHED-LOCAL-FILE-DATABASE: searchArray()=%d', count($searchArray)));
$searchInstance = $dataSetInstance->getSearchInstance();
// Read the directory with some exceptions
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CACHED-LOCAL-FILE-DATABASE: searchInstance=%s', $searchInstance->__toString()));
while (($fileInfoInstance = $directoryInstance->readDirectoryExcept(['.gitkeep', 'info.' . $this->getFileExtension()])) && (($limitFound < $searchInstance->getLimit()) || ($searchInstance->getLimit() == 0))) {
// Does the extension match?
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CACHED-LFDB: fileInfoInstance->extension=' . $fileInfoInstance->getExtension() . ',this->getFileExtension()=' . $this->getFileExtension());
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CACHED-LOCAL-FILE-DATABASE: fileInfoInstance->extension=%s,this->fileExtension=%s', $fileInfoInstance->getExtension(), $this->getFileExtension()));
if ($fileInfoInstance->getExtension() !== $this->getFileExtension()) {
// Skip this file!
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CACHED-LFDB: fileInfoInstance.extension=' . $fileInfoInstance->getExtension() . ',getFileExtension()=' . $this->getFileExtension() . ' - SKIPPED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CACHED-LOCAL-FILE-DATABASE: fileInfoInstance->extension=%s,this->fileExtension=%s - SKIPPED!', $fileInfoInstance->getExtension(), $this->getFileExtension()));
$directoryInstance->getDirectoryIteratorInstance()->next();
continue;
}
// Open this file for reading
$dataArray = $this->getDataArrayFromFile($fileInfoInstance);
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CACHED-LFDB: fileInfoInstance.pathname=' . $fileInfoInstance->getPathname() . ',dataArray='.print_r($dataArray, true));
// Is this an array?
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('CACHED-LOCAL-FILE-DATABASE: fileInfoInstance->pathname=' . $fileInfoInstance->getPathname() . ',dataArray='.print_r($dataArray, true));
if (is_array($dataArray)) {
// Default is nothing found
$isFound = true;
// Search in the criteria with FMFW (First Matches, First Wins)
foreach ($dataArray as $key => $value) {
// Found one entry?
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CACHED-LOCAL-FILE-DATABASE: isFound=%d,key=%s,value[]=%s', intval($isFound), $key, gettype($value)));
$isFound = (($isFound === true) && ($searchInstance->isCriteriaMatching($key, $value)));
}
// Is all found?
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CACHED-LFDB: isFound=' . intval($isFound));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CACHED-LOCAL-FILE-DATABASE: isFound=%s', intval($isFound)));
if ($isFound === true) {
// Shall we skip this entry?
if ($searchInstance->getSkip() > 0) {
// We shall skip some entries
if ($skipFound < $searchInstance->getSkip()) {
// Skip this entry
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CACHED-LFDB: Found entry, but skipping ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('CACHED-LOCAL-FILE-DATABASE: Found entry, but skipping ...');
$skipFound++;
break;
}
// Entry found, so update it
foreach ($searchArray as $searchKey => $searchValue) {
// Make sure the value is not bool again
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CACHED-LOCAL-FILE-DATABASE: searchKey=%s,searchValue[]=%s', $searchKey, gettype($searchValue)));
assert(!is_bool($searchValue));
- assert($searchKey != $this->indexKey);
+ assert($searchKey != $this->getIndexKey());
// Debug message + add/update it
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CACHED-LFDB: criteriaKey=' . $searchKey . ',criteriaValue=' . $searchValue);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CACHED-LOCAL-FILE-DATABASE: criteriaKey=%s,criteriaValue[%s]=%s', $searchKey, gettype($searchValue), $searchValue));
$dataArray[$searchKey] = $searchValue;
}
// Write the data to a local file
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CACHED-LFDB: Writing data[]=' . count($dataArray) . ' to ' . $fileInfoInstance->getPathname() . ' ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CACHED-LOCAL-FILE-DATABASE: Writing data()=%d to %s ...', count($dataArray), $fileInfoInstance->getPathname()));
$this->writeDataArrayToFqfn($fileInfoInstance, $dataArray);
// Count found entries up
}
// Advance to next entry
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CACHED-LOCAL-FILE-DATABASE: Invoking directoryInstance->directoryIteratorInstance->next() ...');
$directoryInstance->getDirectoryIteratorInstance()->next();
}
// Close the file pointer
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CACHED-LOCAL-FILE-DATABASE: Invoking directoryInstance->closeDirectory() ...');
$directoryInstance->closeDirectory();
// Update the primary key
$this->resetLastException();
} catch (FrameworkException $e) {
// Catch all exceptions and store them in last error
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CACHED-LOCAL-FILE-DATABASE: e=%s,e->code=%d,e->message=%s', $e->__toString(), $e->getCode(), $e->getMessage()));
$this->setLastException($e);
// Throw an SQL exception
throw new SqlException(array($this, sprintf('Cannot write data to table '%s', is the table created? Exception: %s, message:%s', $dataSetInstance->getTableName(), $e->__toString(), $e->getMessage()), self::DB_CODE_TABLE_UNWRITEABLE), self::EXCEPTION_SQL_QUERY);
}
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CACHED-LOCAL-FILE-DATABASE: EXIT!');
}
/**
*/
public function getPrimaryKeyOfTable (string $tableName) {
// Validate parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-LOCAL-FILE-DATABASE: tableName=%s - CALLED!', $tableName));
if (empty($tableName)) {
// Throw IAE
- throw new InvalidArgumentException('Parameter "tableName" is empty');
+ throw new InvalidArgumentException('Parameter "tableName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
}
// Default key is null
}
// Return the column
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-LOCAL-FILE-DATABASE: primaryKey[%s]=%s - EXIT!', gettype($primaryKey), $primaryKey));
return $primaryKey;
}
*
* @param $data An array with possible non-public data that needs to be removed.
* @return $data A cleaned up array with only public data.
+ * @throws BadMethodCallException If some non-public is already not found but method was called
* @todo Add more generic non-public data for removal
*/
public function removeNonPublicDataFromArray (array $data) {
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-LOCAL-FILE-DATABASE: data()=%d - CALLED!', count($data)));
+ if (!isset($data[$this->getIndexKey()])) {
+ // Throw BMCE
+ throw new BadMethodCallException(sprintf('data()=%d does not contain this->indexKey=%s', count($data), $this->getIndexKey()));
+ }
+
// Remove '__idx'
- unset($data[$this->indexKey]);
+ unset($data[$this->getIndexKey()]);
// Return it
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CACHED-LFDB: data[' . gettype($data) . ']='.print_r($data, true));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-LOCAL-FILE-DATABASE: data()=%d - EXIT!', count($data)));
return $data;
}
*/
public function countTotalRows (string $tableName) {
// Validate parameter
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CACHED-LFDB: tableName=' . $tableName . ' - CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-LOCAL-FILE-DATABASE: tableName=%s - CALLED!', $tableName));
if (empty($tableName)) {
// Throw IAE
- throw new InvalidArgumentException('Parameter "tableName" is empty');
+ throw new InvalidArgumentException('Parameter "tableName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif (!isset($this->pathNames[$tableName])) {
// "Cache" is not present, so create and assign it
$this->pathNames[$tableName] = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('local_database_path') . $tableName . DIRECTORY_SEPARATOR;
}
// Try all the requests
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CACHED-LFDB: this->pathNames[%s]=%s', $tableName, $this->pathNames[$tableName]));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CACHED-LOCAL-FILE-DATABASE: this->pathNames[%s]=%s', $tableName, $this->pathNames[$tableName]));
try {
// Get a file pointer instance
$directoryInstance = ObjectFactory::createObjectByConfiguredName('directory_class', [$this->pathNames[$tableName]]);
// Read the directory with some exceptions
while ($fileInfoInstance = $directoryInstance->readDirectoryExcept(['.gitkeep', 'info.' . $this->getFileExtension()])) {
// Does the extension match?
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CACHED-LFDB: fileInfoInstance->extension=' . $fileInfoInstance->getExtension() . ',this->getFileExtension()=' . $this->getFileExtension());
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('CACHED-LOCAL-FILE-DATABASE: fileInfoInstance->extension=' . $fileInfoInstance->getExtension() . ',this->getFileExtension()=' . $this->getFileExtension());
if ($fileInfoInstance->getExtension() !== $this->getFileExtension()) {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CACHED-LFDB: fileInfoInstance.extension=' . $fileInfoInstance->getExtension() . ',getFileExtension()=' . $this->getFileExtension() . ' - SKIPPED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('CACHED-LOCAL-FILE-DATABASE: fileInfoInstance->extension=' . $fileInfoInstance->getExtension() . ',getFileExtension()=' . $this->getFileExtension() . ' - SKIPPED!');
// Skip this file!
continue;
}
// Count this row up
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CACHED-LFDB: fileInfoInstance.pathname=' . $fileInfoInstance->getPathname() . ',getFileExtension()=' . $this->getFileExtension() . ' - COUNTED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('CACHED-LOCAL-FILE-DATABASE: fileInfoInstance->pathname=' . $fileInfoInstance->getPathname() . ',getFileExtension()=' . $this->getFileExtension() . ' - COUNTED!');
$count++;
}
} catch (FrameworkException $e) {
}
// Return count
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CACHED-LFDB: tableName=' . $tableName . ',count=' . $count . ' - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-LOCAL-FILE-DATABASE: count=%d - EXIT!', $count));
return $count;
}
* @see DatabaseBackendInterface - An interface for database backends
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
* @see DatabaseBackend - An interface for database backends
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
use Org\Mxchange\CoreFramework\Result\Database\BaseDatabaseResult;
use Org\Mxchange\CoreFramework\Traits\Cache\CacheableTrait;
+// Import SPL stuff
+use \InvalidArgumentException;
+
/**
* A generic database frontend
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
* "Cached" value 'database_cache_enabled' from configuration
*/
private $databaseCacheEnabled = false;
+
/**
* Protected constructor
*
*/
protected function __construct (string $className) {
// Call parent constructor
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-DATABASE-FRONTEND: className=%s - CONSTRUCTED!', $className));
parent::__construct($className);
// Initialize the cache instance
$this->initCacheInstance();
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-DATABASE-FRONTEND: EXIT!');
}
/**
*/
private final function initCacheInstance () {
// Set "cache" attributes
- $this->databaseCacheEnabled = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('database_cache_enabled');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-DATABASE-FRONTEND: CALLED!');
+ $this->databaseCacheEnabled = FrameworkBootstrap::getConfigurationInstance()->isEnabled('database_cache');
// Is the cache enabled?
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-DATABASE-FRONTEND: this->databaseCacheEnabled=%d', intval($this->databaseCacheEnabled)));
if ($this->databaseCacheEnabled === true) {
// Set the new instance
$this->setCacheInstance(ObjectFactory::createObjectByConfiguredName('cache_class'));
}
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-DATABASE-FRONTEND: EXIT!');
}
/**
*/
protected function getCacheKeyByCriteria (Criteria $criteriaInstance, array $onlyKeys = []) {
// Generate it
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FRAMEWORK-SYSTEM: criteriaInstance=' . $criteriaInstance->__toString() . ',onlyKeys()=' . count($onlyKeys) . ' - CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-DATABASE-FRONTEND: criteriaInstance=%s,onlyKeys()=%d - CALLED!', $criteriaInstance->__toString(), count($onlyKeys)));
$cacheKey = sprintf('%s@%s',
$this->__toString(),
$criteriaInstance->getCacheKey($onlyKeys)
);
// And return it
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FRAMEWORK-SYSTEM: cacheKey=' . $cacheKey . ' - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-FRAMEWORK-SYSTEM: cacheKey=' . $cacheKey . ' - EXIT!');
return $cacheKey;
}
*/
protected function queryInsertDataSet (StoreableCriteria $dataSetInstance, array $onlyKeys = []) {
// Default cache key is NULL
- //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FRONTEND: dataSetInstance=%s,onlyKeys()=%d - CALLED!', $dataSetInstance->__toString(), count($onlyKeys)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-DATABASE-FRONTEND: dataSetInstance=%s,onlyKeys()=%d - CALLED!', $dataSetInstance->__toString(), count($onlyKeys)));
$cacheKey = NULL;
// Is cache enabled?
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-DATABASE-FRONTEND: this->databaseCacheEnabled=%d', intval($this->databaseCacheEnabled)));
if ($this->databaseCacheEnabled === true) {
// First get a key suitable for our cache and extend it with this class name
$cacheKey = $this->getCacheKeyByCriteria($dataSetInstance, $onlyKeys);
- //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FRONTEND: Using cache key ' . $cacheKey . ' for purging ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-DATABASE-FRONTEND: Using cache key %s for purging ...', $cacheKey));
}
// Does this key exists in cache?
- //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FRONTEND: cacheKey[%s]=%s', gettype($cacheKey), $cacheKey));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-DATABASE-FRONTEND: this->databaseCacheEnabled=%d,cacheKey[%s]=%s', intval($this->databaseCacheEnabled), gettype($cacheKey), $cacheKey));
if (($this->databaseCacheEnabled === true) && ($this->getCacheInstance()->offsetExists($cacheKey))) {
// Purge the cache
- //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FRONTEND: Calling this->cacheInstance->purgeOffset(%s) ...', $cacheKey));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-DATABASE-FRONTEND: Invoking this->cacheInstance->purgeOffset(%s) ...', $cacheKey));
$this->getCacheInstance()->purgeOffset($cacheKey);
}
FrameworkBootstrap::getDatabaseInstance()->queryInsertDataSet($dataSetInstance);
// Trace message
- //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FRONTEND: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-DATABASE-FRONTEND: EXIT!');
}
/**
*/
protected function queryUpdateDataSet (StoreableCriteria $dataSetInstance, array $onlyKeys = []) {
// Init cache key
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-DATABASE-FRONTEND: dataSetInstance=%s,onlyKeys()=%d - CALLED!', $dataSetInstance->__toString(), count($onlyKeys)));
$cacheKey = NULL;
// Is cache enabled?
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-DATABASE-FRONTEND: this->databaseCacheEnabled=%d', intval($this->databaseCacheEnabled)));
if ($this->databaseCacheEnabled === true) {
// First get a key suitable for our cache and extend it with this class name
$cacheKey = $this->getCacheKeyByCriteria($dataSetInstance, $onlyKeys);
- //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FRONTEND: Using cache key ' . $cacheKey . ' for purging ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('BASE-DATABASE-FRONTEND: Using cache key ' . $cacheKey . ' for purging ...');
}
// Does this key exists in cache?
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-DATABASE-FRONTEND: this->databaseCacheEnabled=%d,cacheKey=%s', intval($this->databaseCacheEnabled), $cacheKey));
if (($this->databaseCacheEnabled === true) && ($this->getCacheInstance()->offsetExists($cacheKey))) {
// Purge the cache
$this->getCacheInstance()->purgeOffset($cacheKey);
// Handle it over to the middleware
FrameworkBootstrap::getDatabaseInstance()->queryUpdateDataSet($dataSetInstance);
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-DATABASE-FRONTEND: EXIT!');
}
/**
* @return $indexKey Index key
*/
public final function getIndexKey () {
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-DATABASE-FRONTEND: CALLED!');
return FrameworkBootstrap::getDatabaseInstance()->getIndexKey();
}
* @return $lastException Last exception or NULL if none occured
*/
public final function getLastException () {
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-DATABASE-FRONTEND: CALLED!');
return FrameworkBootstrap::getDatabaseInstance()->getLastException();
}
*/
public function doSelectByCriteria (Criteria $criteriaInstance, array $onlyKeys = []) {
// Default cache key if cache is not enabled
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FRONTEND: criteriaInstance=%s,onlyKeys()=%d - CALLED!', $criteriaInstance->__toString(), count($onlyKeys)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-DATABASE-FRONTEND: criteriaInstance=%s,onlyKeys()=%d - CALLED!', $criteriaInstance->__toString(), count($onlyKeys)));
$cacheKey = NULL;
$result = [];
// Is the cache enabled?
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-DATABASE-FRONTEND: this->databaseCacheEnabled=%d', intval($this->databaseCacheEnabled)));
if ($this->databaseCacheEnabled === true) {
// First get a key suitable for our cache and extend it with this class name
$cacheKey = $this->getCacheKeyByCriteria($criteriaInstance, $onlyKeys);
}
// Does this key exists in cache?
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FRONTEND: cacheKey[%s]=%s', gettype($cacheKey), $cacheKey));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-DATABASE-FRONTEND: this->databaseCacheEnabled=%d,cacheKey[%s]=%s', intval($this->databaseCacheEnabled), gettype($cacheKey), $cacheKey));
if (($this->databaseCacheEnabled === true) && ($this->getCacheInstance()->offsetExists($cacheKey, BaseDatabaseResult::RESULT_NAME_ROWS, 1))) {
// Then use this result
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FRONTEND: Cache used for cacheKey=%s', $cacheKey));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-DATABASE-FRONTEND: Cache used for cacheKey=%s', $cacheKey));
$result = $this->getCacheInstance()->offsetGet($cacheKey);
} else {
// Now it's time to ask the database layer for this select statement
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FRONTEND: Quering database, cacheKey=%s ...', $cacheKey));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-DATABASE-FRONTEND: Quering database, cacheKey=%s ...', $cacheKey));
$result = FrameworkBootstrap::getDatabaseInstance()->doSelectByTableCriteria($this->getTableName(), $criteriaInstance);
// Cache the result if not null
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FRONTEND: result[]=%s', gettype($result)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-DATABASE-FRONTEND: result[]=%s', gettype($result)));
if (!is_null($result)) {
// Is cache enabled?
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-DATABASE-FRONTEND: this->databaseCacheEnabled=%d', intval($this->databaseCacheEnabled)));
if ($this->databaseCacheEnabled === true) {
// A valid result has returned from the database layer
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FRONTEND: Setting cacheKey=%s with result()=%d entries', $cacheKey, count($result)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-DATABASE-FRONTEND: Setting cacheKey=%s with result()=%d entries', $cacheKey, count($result)));
$this->getCacheInstance()->offsetSet($cacheKey, $result);
}
} else {
// This invalid result must be wrapped
- $result = array(
+ $result = [
BaseDatabaseResult::RESULT_NAME_STATUS => 'invalid',
- BaseDatabaseResult::RESULT_NAME_EXCEPTION => FrameworkBootstrap::getDatabaseInstance()->getLastException()
- );
+ BaseDatabaseResult::RESULT_NAME_EXCEPTION => FrameworkBootstrap::getDatabaseInstance()->getLastException(),
+ ];
}
}
// Create an instance of a CachedDatabaseResult class with the given result
// @TODO Minor: Update above comment to e.g. BaseDatabaseResult
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FRONTEND: result[%s]=%s,result[%s]?=%d,result[%s]?=%d', BaseDatabaseResult::RESULT_NAME_STATUS, $result[BaseDatabaseResult::RESULT_NAME_STATUS], BaseDatabaseResult::RESULT_NAME_ROWS, isset($result[BaseDatabaseResult::RESULT_NAME_ROWS]), BaseDatabaseResult::RESULT_NAME_EXCEPTION, isset($result[BaseDatabaseResult::RESULT_NAME_EXCEPTION])));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-DATABASE-FRONTEND: result[%s]=%s,result[%s]?=%d,result[%s]?=%d', BaseDatabaseResult::RESULT_NAME_STATUS, $result[BaseDatabaseResult::RESULT_NAME_STATUS], BaseDatabaseResult::RESULT_NAME_ROWS, isset($result[BaseDatabaseResult::RESULT_NAME_ROWS]), BaseDatabaseResult::RESULT_NAME_EXCEPTION, isset($result[BaseDatabaseResult::RESULT_NAME_EXCEPTION])));
$resultInstance = ObjectFactory::createObjectByConfiguredName('database_result_class', array($result));
// And return the instance
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FRONTEND: resultInstance=%s - EXIT!', $resultInstance->__toString()));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-DATABASE-FRONTEND: resultInstance=%s - EXIT!', $resultInstance->__toString()));
return $resultInstance;
}
*/
public function doSelectCountByCriteria (Criteria $criteriaInstance, array $onlyKeys = []) {
// Total numbers is -1 so we can distinglish between failed and valid queries
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-DATABASE-FRONTEND: criteriaInstance=%s,onlyKeys()=%d - CALLED!', $criteriaInstance->__toString(), count($onlyKeys)));
$numRows = 0;
// Get the result from above method
$resultInstance = $this->doSelectByCriteria($criteriaInstance, $onlyKeys);
// Was that query fine?
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-DATABASE-FRONTEND: resultInstance->ifStatusIsOkay()=%d', $resultInstance->ifStatusIsOkay()));
if ($resultInstance->ifStatusIsOkay()) {
// Then get the number of rows
$numRows = $resultInstance->getAffectedRows();
-
- // Debug message
- //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FRONTEND: numRows=' . $numRows);
}
// Return the result
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-DATABASE-FRONTEND: numRows=%d - EXIT!', $numRows));
return $numRows;
}
/**
- * Getter for primary key used in wrapped table
+ * Generates a primary key for this database frontend
*
* @return $primaryKey Primary key used in wrapped table
*/
- public final function getPrimaryKeyValue () {
+ public final function generatePrimaryKey () {
// Get the table name and a database instance and ask for it
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-DATABASE-FRONTEND: CALLED!');
$primaryKey = FrameworkBootstrap::getDatabaseInstance()->getPrimaryKeyOfTable($this->getTableName());
// Return value
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-DATABASE-FRONTEND: primaryKey=%s - EXIT!', $primaryKey));
return $primaryKey;
}
*/
public final function countTotalRows () {
// Get the table name and a database instance and ask for it
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-DATABASE-FRONTEND: CALLED!');
$count = FrameworkBootstrap::getDatabaseInstance()->countTotalRows($this->getTableName());
// Return value
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-DATABASE-FRONTEND: count=%d - EXIT!', $count));
return $count;
}
*
* @param $data An array with possible non-public data that needs to be removed.
* @return $data A cleaned up array with only public data.
+ * @throws InvalidArgumentException If a parameter has an invalid value
*/
public function removeNonPublicDataFromArray (array $data) {
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('WRAPPER[' . $this->__toString() . ']: Calling FrameworkBootstrap::getDatabaseInstance()->removeNonPublicDataFromArray(data) ...');
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-DATABASE-FRONTEND: data()=%d - CALLED!', count($data)));
+ if (count($data) == 0) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "data" is an empty array', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
+ // Remove non-public data (aka. sensitive)
$data = FrameworkBootstrap::getDatabaseInstance()->removeNonPublicDataFromArray($data);
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('WRAPPER[' . $this->__toString() . ']: data[]=' . gettype($data));
+ // Return cleaned array
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-DATABASE-FRONTEND: data()=%d - EXIT!', count($data)));
return $data;
}
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @todo Add missing own interface for public methods
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @todo Add missing own interface for public methods
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Is this null?
if (is_null($updateInstance)) {
// Throw an exception here
- throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
+ throw new NullPointerException($this, FrameworkInterface::EXCEPTION_IS_NULL_POINTER);
}
// Get search instance from update instance
// Is it still null?
if (is_null($searchInstance)) {
// Throw an exception here
- throw new NullPointerException($updateInstance, self::EXCEPTION_IS_NULL_POINTER);
+ throw new NullPointerException($updateInstance, FrameworkInterface::EXCEPTION_IS_NULL_POINTER);
}
}
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*/
private function __construct () {
// Call parent constructor
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CACHED-DATABASE-RESULT: CONSTRUCTED!');
parent::__construct(__CLASS__);
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CACHED-DATABASE-RESULT: EXIT!');
}
/**
*/
public static final function createCachedDatabaseResult (array $resultArray) {
// Misses an element?
+ //* DEBUG-DIE: */ die(sprintf('[%s:%d]: resultArray=%s', __METHOD__, __LINE__, print_r($resultArray, true)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-DATABASE-RESULT: resultArray()=%d - CALLED!', count($resultArray)));
if (count($resultArray) == 0) {
// Cannot be empty
- throw new InvalidArgumentException('Array "resultArray" is empty');
+ throw new InvalidArgumentException('Array "resultArray" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif (!array_key_exists(BaseDatabaseResult::RESULT_NAME_ROWS, $resultArray)) {
// Yes, then abort here
throw new InvalidArgumentException(sprintf('resultArray(%d)=%s has no element "%s".', count($resultArray), print_r($resultArray, TRUE), BaseDatabaseResult::RESULT_NAME_ROWS));
+ } elseif (!array_key_exists(BaseDatabaseResult::RESULT_NAME_STATUS, $resultArray)) {
+ // Yes, then abort here
+ throw new InvalidArgumentException(sprintf('resultArray(%d)=%s has no element "%s".', count($resultArray), print_r($resultArray, TRUE), BaseDatabaseResult::RESULT_NAME_STATUS));
}
// Get a new instance
$resultInstance = new CachedDatabaseResult();
- // Set the result array and reset current position
+ // Set the result array
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CACHED-DATABASE-RESULT: Setting resultArray()=%d ...', count($resultArray)));
$resultInstance->setResultArray($resultArray);
+
+ // Reset current position
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CACHED-DATABASE-RESULT: Invoking resultInstance->resetCurrentPosition() ...');
$resultInstance->resetCurrentPosition();
// Set affected rows
$resultInstance->setAffectedRows(count($resultArray[BaseDatabaseResult::RESULT_NAME_ROWS]));
// Return the instance
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-DATABASE-RESULT: resultInstance=%s - EXIT!', $resultInstance->__toString()));
return $resultInstance;
}
*/
private function updateCurrentEntryByCriteria (LocalUpdateCriteria $updateInstance) {
// Get the current entry key
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-DATABASE-RESULT: updateInstance=%s - CALLED!', $updateInstance->__toString()));
$entryKey = $this->key();
// Now get the update criteria array and update all entries
foreach ($updateInstance->getUpdateCriteria() as $criteriaKey => $criteriaValue) {
// Update data
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CACHED-DATABASE-RESULT: criteriaKey=%s,criteriaValue[%s]=%s', $criteriaKey, gettype($criteriaValue), $criteriaValue));
$this->resultArray[BaseDatabaseResult::RESULT_NAME_ROWS][$entryKey][$criteriaKey] = $criteriaValue;
// Mark it as out-dated
$this->outDated[$criteriaKey] = 1;
}
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CACHED-DATABASE-RESULT: EXIT!');
}
/**
*/
public function next () {
// Default is not valid
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CACHED-DATABASE-RESULT: CALLED!');
$nextValid = false;
// Increase position
}
// Return the result
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-DATABASE-RESULT: nextValid=%d - EXIT!', intval($nextValid)));
return $nextValid;
}
*/
public function seek (int $seekPosition) {
// Validate parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-DATABASE-RESULT: seekPosition=%d - CALLED!', $seekPosition));
if ($seekPosition < 0) {
// Throw exception
throw new OutOfBoundsException(sprintf('seekPositon=%d is not seekable', $seekPosition));
$this->rewind();
// Search for the entry
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CACHED-DATABASE-RESULT: this->currentPos=%d,seekPosition=%d', $this->currentPos, $seekPosition));
while (($this->currentPos < $seekPosition) && ($this->valid())) {
// Continue on
$this->next();
}
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CACHED-DATABASE-RESULT: EXIT!');
}
/**
*/
public function current () {
// Default is not found
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CACHED-DATABASE-RESULT: CALLED!');
$current = NULL;
// Does the current enty exist?
}
// Return the result
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-DATABASE-RESULT: current[]=%s - EXIT!', gettype($current)));
return $current;
}
*/
public function valid () {
// Check if all is fine ...
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CACHED-DATABASE-RESULT: this->currentPos=%d - CALLED!', $this->currentPos));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-DATABASE-RESULT: this->currentPos=%d - CALLED!', $this->currentPos));
$isValid = ($this->ifStatusIsOkay() && isset($this->resultArray[BaseDatabaseResult::RESULT_NAME_ROWS][$this->currentPos]) && isset($this->resultArray[BaseDatabaseResult::RESULT_NAME_ROWS][0]));
// Return the result
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CACHED-DATABASE-RESULT: isValid=%d - EXIT!', intval($isValid)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-DATABASE-RESULT: isValid=%d - EXIT!', intval($isValid)));
return $isValid;
}
*/
public function count () {
// Count rows
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CACHED-DATABASE-RESULT: CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CACHED-DATABASE-RESULT: CALLED!');
$count = count($this->resultArray[BaseDatabaseResult::RESULT_NAME_ROWS]);
// Return it
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CACHED-DATABASE-RESULT: count=%d - EXIT!', $count));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-DATABASE-RESULT: count=%d - EXIT!', $count));
return $count;
}
*/
public function ifStatusIsOkay () {
// Check all conditions
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CACHED-DATABASE-RESULT: this->currentPos=%d - CALLED!', $this->currentPos));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-DATABASE-RESULT: this->currentPos=%d - CALLED!', $this->currentPos));
$ifStatusOkay = (isset($this->resultArray[BaseDatabaseResult::RESULT_NAME_STATUS]) && $this->resultArray[BaseDatabaseResult::RESULT_NAME_STATUS] === BaseDatabaseBackend::RESULT_OKAY);
// Return status
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CACHED-DATABASE-RESULT: ifStatusOkay=%s - EXIT!', intval($ifStatusOkay)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-DATABASE-RESULT: ifStatusOkay=%s - EXIT!', intval($ifStatusOkay)));
return $ifStatusOkay;
}
*/
public function key () {
// Return current array position
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CACHED-DATABASE-RESULT: this->currentPos=%d - CALLED!', $this->currentPos));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-DATABASE-RESULT: this->currentPos=%d - CALLED!', $this->currentPos));
return $this->currentPos;
}
*/
public function rewind () {
// Reset both current array position and current row
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CACHED-DATABASE-RESULT: this->currentPos=%d - CALLED!', $this->currentPos));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-DATABASE-RESULT: this->currentPos=%d - CALLED!', $this->currentPos));
$this->resetCurrentPosition();
$this->currentRow = [];
// Trace message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CACHED-DATABASE-RESULT: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CACHED-DATABASE-RESULT: EXIT!');
}
/**
*/
private function resetCurrentPosition () {
// Reset position
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CACHED-DATABASE-RESULT: CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CACHED-DATABASE-RESULT: CALLED!');
$this->currentPos = ($this->count() > 0 ? 0 : -1);
// Trace message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CACHED-DATABASE-RESULT: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-DATABASE-RESULT: this->currentPos=%d - EXIT!', $this->currentPos));
}
/**
*/
public function add2UpdateQueue (LocalUpdateCriteria $updateInstance) {
// Rewind the pointer
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-DATABASE-RESULT: updateInstance=%s - CALLED!', $updateInstance->__toString()));
$this->rewind();
// Get search criteria
$searchInstance = $updateInstance->getSearchInstance();
- // And start looking for the result
+ // Get affected rows
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CACHED-DATABASE-RESULT: searchInstance=%s', $searchInstance->__toString()));
$foundEntries = $this->getAffectedRows();
+
+ // And start looking for the result
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CACHED-DATABASE-RESULT: foundEntries=%d,searchInstance->limit=%d', $foundEntries, $searchInstance->getLimit()));
while (($this->valid()) && ($foundEntries < $searchInstance->getLimit())) {
// Get next entry
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CACHED-DATABASE-RESULT: Invoking this->next() ...');
$this->next();
+
+ // Get current entry
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CACHED-DATABASE-RESULT: Invoking this->current() ...');
$currentEntry = $this->current();
// Is this entry found?
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-DATABASE-RESULT: currentEntry[]=%s - EXIT!', gettype($currentEntry)));
if ($searchInstance->ifEntryMatches($currentEntry)) {
// Update this entry
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-DATABASE-RESULT: Invoking this->updateCurrentEntryByCriteria(%s) ...', $updateInstance->__toString()));
$this->updateCurrentEntryByCriteria($updateInstance);
// Count one up
$foundEntries++;
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CACHED-DATABASE-RESULT: foundEntries=%d', $foundEntries));
}
}
// If no entry is found/updated throw an exception
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CACHED-DATABASE-RESULT: foundEntries=%d', $foundEntries));
if ($foundEntries == 0) {
// Throw an exception here
throw new ResultUpdateException($this, self::EXCEPTION_RESULT_UPDATE_FAILED);
}
// Set affected rows
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-DATABASE-RESULT: Invoking this->setAffectedRows(%d) ...', $foundEntries));
$this->setAffectedRows($foundEntries);
// Set update instance
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-DATABASE-RESULT: Invoking this->setUpdateInstance(%s) ...', $updateInstance->__toString()));
$this->setUpdateInstance($updateInstance);
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CACHED-DATABASE-RESULT: EXIT!');
}
/**
* @return $needsUpdate Whether we have out-dated entries
*/
public function ifDataNeedsFlush () {
+ // Check if records are out-dated
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CACHED-DATABASE-RESULT: CALLED!');
$needsUpdate = (count($this->outDated) > 0);
+
+ // Return it
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-DATABASE-RESULT: needsUpdate=%d - EXIT!', intval($needsUpdate)));
return $needsUpdate;
}
*/
public function addElementsToDataSet (StoreableCriteria $criteriaInstance) {
// Walk only through out-dated columns
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-DATABASE-RESULT: criteriaInstance=%s - CALLED!', $criteriaInstance->__toString()));
foreach ($this->outDated as $key => $dummy) {
// Does this key exist?
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CACHED-DATABASE-RESULT: key=%s,dummy[]=%s', $key, gettype($dummy)));
if ($this->find($key)) {
// Then update it
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-DATABASE-RESULT: Invoking criteriaInstance->addCriteria(%s,foundValue[]=%s) ...', $key, gettype($this->getFoundValue())));
$criteriaInstance->addCriteria($key, $this->getFoundValue());
}
}
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CACHED-DATABASE-RESULT: EXIT!');
}
/**
*
* @param $key The key we shall find
* @return $found Whether the key was found or not
+ * @throws InvalidArgumentException If a parameter is invalid
*/
public function find (string $key) {
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-DATABASE-RESULT: key=%s - CALLED!', $key));
+ if (empty($key)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "key" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// By default nothing is found
$found = false;
// Rewind the pointer
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CACHED-DATABASE-RESULT: Invoking this->rewind() ...');
$this->rewind();
// Walk through all entries
while ($this->valid()) {
// Advance to next entry
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CACHED-DATABASE-RESULT: Invoking this->next() ...');
$this->next();
// Get the whole array
$currentEntry = $this->current();
// Is the element there?
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-DATABASE-RESULT: currentEntry[]=%s - EXIT!', gettype($currentEntry)));
if (isset($currentEntry[$key])) {
// Okay, found!
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CACHED-DATABASE-RESULT: key=%s is found in currentEntry', $key));
$found = true;
// So "cache" it
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CACHED-DATABASE-RESULT: Setting this->foundValue to currentEntry[%s][]=%s is found in currentEntry', $key, gettype($currentEntry[$key])));
$this->foundValue = $currentEntry[$key];
// And stop searching
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('CACHED-DATABASE-RESULT: BREAK!');
break;
}
}
// Return the result
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-DATABASE-RESULT: found=%d - EXIT!', intval($found)));
return $found;
}
*
* @param $databaseColumn Database column where the index might be found
* @param $frontendInstance The frontend instance to ask for array element
- * @para $callBack Call-back object for setting the index;
+ * @para $callback Call-back object for setting the index;
* 0=object instance,1=method name
* @return void
+ * @throws InvalidArgumentException If a parameter is invalid
* @todo Find a caching way without modifying the result array
*/
- public function solveResultIndex (string $databaseColumn, DatabaseFrontend $frontendInstance, array $callBack) {
+ public function solveResultIndex (string $databaseColumn, DatabaseFrontend $frontendInstance, array $callback) {
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-DATABASE-RESULT: databaseColumn=%s,frontendInstance=%s,callback()=%d - CALLED!', $databaseColumn, $frontendInstance->__toString(), count($callback)));
+ if (empty($key)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "key" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (count($callback) != 2) {
+ // Throw it again
+ throw new InvalidArgumentException(sprintf('callback()=%d must be exactly 2', count($callback)), FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (!is_callable($callback)) {
+ // Throw it again
+ throw new InvalidArgumentException(sprintf('%s:%s() is not callable', $callback[0], $callback[1]), FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// By default nothing is found
$indexValue = 0;
// Is the element in result itself found?
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-DATABASE-RESULT: Invoking this->find(%s),frontendInstance->indexKey=%s ...', $databaseColumn, $frontendInstance->getIndexKey()));
if ($this->find($databaseColumn)) {
// Use this value
$indexValue = $this->getFoundValue();
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CACHED-DATABASE-RESULT: indexValue[]=%s from this->find(%s) - databaseColumn', gettype($indexValue), $databaseColumn));
} elseif ($this->find($frontendInstance->getIndexKey())) {
// Use this value
$indexValue = $this->getFoundValue();
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CACHED-DATABASE-RESULT: indexValue[]=%s from this->find(%s) - frontendInstance->indexKey', gettype($indexValue), $frontendInstance->getIndexKey()));
}
// Set the index
- call_user_func_array($callBack, array($indexValue));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-DATABASE-RESULT: Invoking %s:%s(indexValue[]=%s) ...', $callback[0], $callback[1], gettype($indexValue)));
+ call_user_func_array($callback, [$indexValue]);
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CACHED-DATABASE-RESULT: EXIT!');
}
}
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Import framework stuff
use Org\Mxchange\CoreFramework\Helper\Template\HelpableTemplate;
+use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
/**
* A ??? discovery class.
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
* @todo 0% done
*/
public function discover (Requestable $requestInstance) {
- $this->partialStub("Please implement this method.");
+ DebugMiddleware::getSelfInstance()->partialStub("Please implement this method.");
}
/**
* @todo 0% done
*/
public function addResultsToHelper (HelpableTemplate $helperInstance) {
- $this->partialStub("Please implement this method.");
+ DebugMiddleware::getSelfInstance()->partialStub("Please implement this method.");
}
}
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
namespace Org\Mxchange\CoreFramework\Factory;
// Import framework stuff
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
// Import SPL stuff
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Is the parameter valid?
if (empty($fullClassName)) {
// No empty class name
- throw new InvalidArgumentException('fullClassName is empty', self::EXCEPTION_CONFIG_KEY_IS_EMPTY);
+ throw new InvalidArgumentException('fullClassName is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
}
// Count it up in total sum
// Is the parameter valid?
if (empty($fullClassName)) {
// No empty class name
- throw new InvalidArgumentException('fullClassName is empty', self::EXCEPTION_CONFIG_KEY_IS_EMPTY);
+ throw new InvalidArgumentException('fullClassName is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
}
// Return isset() result
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
$registryKey = strtolower($protocolInstance->getProtocolName()) . '_client';
// Is the key already in registry?
- if (GenericRegistry::getRegistry()->instanceExists($registryKey)) {
+ if (ObjectRegistry::getRegistry('factory')->instanceExists($registryKey)) {
// Then use that instance
- $clientInstance = GenericRegistry::getRegistry()->getInstance($registryKey);
+ $clientInstance = ObjectRegistry::getRegistry('factory')->getInstance($registryKey);
// Set socket resource
$clientInstance->setSocketResource($socketResource);
$clientInstance = ObjectFactory::createObjectByConfiguredName($registryKey, array($socketResource));
// Set it in registry for later re-use
- GenericRegistry::getRegistry()->addInstance($registryKey, $clientInstance);
+ ObjectRegistry::getRegistry('factory')->addInstance($registryKey, $clientInstance);
}
// Return the prepared instance
// Import framework stuff
use Org\Mxchange\CoreFramework\Factory\BaseFactory;
use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
+use Org\Mxchange\CoreFramework\Registry\Object\ObjectRegistry;
+
+// Import SPL stuff
+use \InvalidArgumentException;
/**
* A factory class for socket registries
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class DatabaseFrontendFactory extends BaseFactory {
+ /**
+ * "Cache" for frontend factory
+ */
+ private static $registryInstance = NULL;
+
/**
* Protected constructor
*
parent::__construct(__CLASS__);
}
+ /**
+ * Some "static initializer
+ *
+ * @return void
+ */
+ public final static function staticInitializer () {
+ // Is it initialized?
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('frontend-FACTORY: self::registryInstance[]=%s - CALLED!', gettype(self::$registryInstance)));
+ if (is_null(self::$registryInstance)) {
+ // No, then initialize it
+ self::$registryInstance = ObjectRegistry::getRegistry('factory');
+ }
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('frontend-FACTORY: self::registryInstance=%s - EXIT!', self::$registryInstance));
+ }
+
/**
* Returns a singleton socket registry instance. If an instance is found in
* the registry it will be returned, else a new instance is created and
* @return $frontendInstance A database frontend instance
*/
public static final function createFrontendByConfiguredName (string $frontendName) {
- // Get registry instance
- $registryInstance = GenericRegistry::getRegistry();
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('DATABASE-FRONTEND-FACTORY: frontendName=%s - CALLED!', $frontendName));
+ if (empty($frontendName)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "frontendName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
+ // Invoke "static initializer"
+ self::staticInitializer();
// Do we have an instance in the registry?
- if ($registryInstance->instanceExists($frontendName)) {
+ if (self::$registryInstance->instanceExists($frontendName)) {
// Then use this instance
- $frontendInstance = $registryInstance->getInstance($frontendName);
+ $frontendInstance = self::$registryInstance->getInstance($frontendName);
} else {
// Get the registry instance
$frontendInstance = ObjectFactory::createObjectByConfiguredName($frontendName);
// Set the instance in registry for further use
- $registryInstance->addInstance($frontendName, $frontendInstance);
+ self::$registryInstance->addInstance($frontendName, $frontendInstance);
}
// Return the instance
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('DATABASE-FRONTEND-FACTORY: frontendInstance=%s - EXIT!', $frontendInstance->__toString()));
return $frontendInstance;
}
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Import framework stuff
use Org\Mxchange\CoreFramework\Factory\BaseFactory;
use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
+use Org\Mxchange\CoreFramework\Registry\Object\ObjectRegistry;
// Import SPL stuff
use \InvalidArgumentException;
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
// If there is no handler?
if (empty($type)) {
// Throw IAE
- throw new InvalidArgumentException('Parameter "type" is empty');
- } elseif (GenericRegistry::getRegistry()->instanceExists($type . '_index')) {
+ throw new InvalidArgumentException('Parameter "type" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (ObjectRegistry::getRegistry('factory')->instanceExists($type . '_index')) {
// Get handler from registry
- $indexInstance = GenericRegistry::getRegistry()->getInstance($type . '_index');
+ $indexInstance = ObjectRegistry::getRegistry('factory')->getInstance($type . '_index');
} else {
// Get the handler instance
$indexInstance = ObjectFactory::createObjectByConfiguredName($type . '_file_stack_index_class', [$fileInfoInstance]);
// Add it to the registry
- GenericRegistry::getRegistry()->addInstance($type . '_index', $indexInstance);
+ ObjectRegistry::getRegistry('factory')->addInstance($type . '_index', $indexInstance);
}
// Return the instance
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Import framework stuff
use Org\Mxchange\CoreFramework\Factory\BaseFactory;
use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
+use Org\Mxchange\CoreFramework\Registry\Object\ObjectRegistry;
use Org\Mxchange\CoreFramework\Request\Requestable;
/**
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*/
public static final function createLoginObjectByRequest (Requestable $requestInstance) {
// Get registry instance
- $registryInstance = GenericRegistry::getRegistry();
+ $registryInstance = ObjectRegistry::getRegistry('factory');
// Do we have an instance in the registry?
if ($registryInstance->instanceExists('login_helper')) {
// Import framework stuff
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
use Org\Mxchange\CoreFramework\Factory\BaseFactory;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Loader\NoClassException;
// Import SPL stuff
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Is the class name valid and is the class there?
if (empty($fullClassName)) {
// Throw an exception here
- throw new InvalidArgumentException('Parameter "fullClassName" is empty');
+ throw new InvalidArgumentException('Parameter "fullClassName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif (!self::isClassCounted($fullClassName) && !class_exists($fullClassName)) {
// First get an instance of this factory
$factoryInstance = new ObjectFactory();
// Then throw an exception
- throw new NoClassException(array($factoryInstance, $fullClassName), self::EXCEPTION_CLASS_NOT_FOUND);
+ throw new NoClassException([$factoryInstance, $fullClassName], FrameworkInterface::EXCEPTION_CLASS_NOT_FOUND);
}
// Split class name on backslash to check naming-convention
// Import framework stuff
use Org\Mxchange\CoreFramework\Factory\BaseFactory;
use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
+use Org\Mxchange\CoreFramework\Registry\Object\ObjectRegistry;
/**
* A factory class for socket registries
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*/
public static final function createSocketRegistryInstance () {
// Get registry instance
- $registryInstance = GenericRegistry::getRegistry();
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('SOCKET-REGISTRY-FACTORY: CALLED!');
+ $objectRegistryInstance = ObjectRegistry::getRegistry('factory');
// Do we have an instance in the registry?
- if ($registryInstance->instanceExists('socket_registry')) {
+ if ($objectRegistryInstance->instanceExists('socket_registry')) {
// Then use this instance
- $registryInstance = $registryInstance->getInstance('socket_registry');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('SOCKET-REGISTRY-FACTORY: Getting socket registry instance ...');
+ $registryInstance = $objectRegistryInstance->getInstance('socket_registry');
} else {
// Get the registry instance
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('SOCKET-REGISTRY-FACTORY: Creating new socket registry instance ...');
$registryInstance = ObjectFactory::createObjectByConfiguredName('socket_registry_class');
// Set the instance in registry for further use
- $registryInstance->addInstance('socket_registry', $registryInstance);
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('SOCKET-REGISTRY-FACTORY: Adding socket registry instance ...');
+ $objectRegistryInstance->addInstance('socket_registry', $registryInstance);
}
// Return the instance
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('SOCKET-REGISTRY-FACTORY: registryInstance=%s - EXIT!', $registryInstance->__toString()));
return $registryInstance;
}
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
use Org\Mxchange\CoreFramework\Factory\BaseFactory;
use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
+use Org\Mxchange\CoreFramework\Registry\Object\ObjectRegistry;
// Import SPL stuff
use \InvalidArgumentException;
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
//* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-STACK-FACTORY: prefix=%s,stackName=%s - CALLED!', $prefix, $stackName));
if (empty($prefix)) {
// Throw IAE
- throw new InvalidArgumentException('Parameter "prefix" is empty');
+ throw new InvalidArgumentException('Parameter "prefix" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif (empty($stackName)) {
// Throw it again
- throw new InvalidArgumentException('Paramter "stackName" is empty');
+ throw new InvalidArgumentException('Paramter "stackName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
}
// Construct file stack name
));
// If there is no handler?
- if (GenericRegistry::getRegistry()->instanceExists($stackName . '_stack')) {
+ if (ObjectRegistry::getRegistry('factory')->instanceExists($stackName . '_stack')) {
// Get handler from registry
- $stackInstance = GenericRegistry::getRegistry()->getInstance($stackName . '_stack');
+ $stackInstance = ObjectRegistry::getRegistry('factory')->getInstance($stackName . '_stack');
} else {
// Get the handler instance
$stackInstance = ObjectFactory::createObjectByConfiguredName($prefix . '_' . $stackName . '_stack_class', array($fileInfoInstance, $prefix . '_' . $stackName));
// Add it to the registry
- GenericRegistry::getRegistry()->addInstance($stackName . '_stack', $stackInstance);
+ ObjectRegistry::getRegistry('factory')->addInstance($stackName . '_stack', $stackInstance);
}
// Return the instance
// Import framework stuff
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
use Org\Mxchange\CoreFramework\Factory\BaseFactory;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
+use Org\Mxchange\CoreFramework\Registry\Object\ObjectRegistry;
use Org\Mxchange\CoreFramework\Request\Requestable;
/**
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*/
public static final function createUserByRequest (Requestable $requestInstance) {
// Get registry instance
- $registryInstance = GenericRegistry::getRegistry();
+ $registryInstance = ObjectRegistry::getRegistry('factory');
// Do we have an instance in the registry?
if ($registryInstance->instanceExists('user')) {
// Import framework stuff
use Org\Mxchange\CoreFramework\Factory\BaseFactory;
use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
+use Org\Mxchange\CoreFramework\Registry\Object\ObjectRegistry;
// Import SPL stuff
use \InvalidArgumentException;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('XML-TEMPLATE-ENGINE-FACTORY: configKey=%s - CALLED!', $configKey));
if (empty($configKey)) {
// Throw IAE
- throw new InvalidArgumentException('Paramter "configKey" is empty');
+ throw new InvalidArgumentException('Paramter "configKey" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
}
// Do we have an instance in the registry?
- if (GenericRegistry::getRegistry()->instanceExists($configKey)) {
+ if (ObjectRegistry::getRegistry('factory')->instanceExists($configKey)) {
// Then use this instance
- $templateInstance = GenericRegistry::getRegistry()->getInstance($configKey);
+ $templateInstance = ObjectRegistry::getRegistry('factory')->getInstance($configKey);
} else {
// Get the XML template instance
$templateInstance = ObjectFactory::createObjectByConfiguredName($configKey);
$templateInstance->enableXmlCompacting();
// Set the instance in registry for further use
- GenericRegistry::getRegistry()->addInstance($configKey, $templateInstance);
+ ObjectRegistry::getRegistry('factory')->addInstance($configKey, $templateInstance);
}
// Return the instance
// Import framework stuff
use Org\Mxchange\CoreFramework\Feature\BaseFeature;
use Org\Mxchange\CoreFramework\Feature\Feature;
+use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
/**
* A ??? feature class
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
$isAvailable = false;
// Unfinished:
- $this->partialStub('Please implement this method.');
+ DebugMiddleware::getSelfInstance()->partialStub('Please implement this method.');
// Return status
return $isAvailable;
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
// Import framework stuff
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Loader\NoClassException;
use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
use Org\Mxchange\CoreFramework\Utils\Strings\StringUtils;
+// Import SPL stuff
+use \BadMethodCallException;
+use \InvalidArgumentException;
+
/**
* The general feature management class. No instance is needed as this class
* has only public methods that are static.
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
*
* @param $featureName Name of the feature to be checked
* @return $isEnabled Whether the given feature is enabled
+ * @throws InvalidArgumentException If a parameter is invalid
*/
public static function isFeatureEnabled (string $featureName) {
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('FRAMEWORK-FEATURE: featureName=%s - CALLED!', $featureName));
+ if (empty($featureName)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "featureName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Is the cache set?
if (!isset(self::$enabledFeatures[$featureName]['is_enabled'])) {
// Generate config key
}
// Return "cached" status
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('FRAMEWORK-FEATURE: is_enabled[%s]=%d - EXIT!', $featureName, intval(self::$enabledFeatures[$featureName]['is_enabled'])));
return self::$enabledFeatures[$featureName]['is_enabled'];
}
*
* @param $featureName Name of the feature to be checked on availability
* @return $isAvailable Whether the given feature is available
+ * @throws InvalidArgumentException If a parameter is invalid
*/
public static function isFeatureAvailable (string $featureName) {
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('FRAMEWORK-FEATURE: featureName=%s - CALLED!', $featureName));
+ if (empty($featureName)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "featureName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Is the cache set?
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FRAMEWORK-FEATURE: featureName=%s - CALLED!', $featureName));
if (!isset(self::$enabledFeatures[$featureName]['is_available'])) {
// Default is not available
self::$enabledFeatures[$featureName]['is_available'] = false;
// Is the feature enabled?
if (!self::isFeatureEnabled($featureName)) {
// Then it can't be available
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FRAMEWORK-FEATURE: Feature "%s"is not enabled.', $featureName));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('FRAMEWORK-FEATURE: Feature "%s"is not enabled. - EXIT!', $featureName));
return false;
}
$configKey = sprintf('feature_%s_class', $featureName);
// Now try to get the instance
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FRAMEWORK-FEATURE: configKey=%s', $configKey));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('FRAMEWORK-FEATURE: configKey=%s', $configKey));
try {
// Try to get an instance
self::$enabledFeatures[$featureName]['instance'] = ObjectFactory::createObjectByConfiguredName($configKey);
self::$enabledFeatures[$featureName]['is_available'] = self::$enabledFeatures[$featureName]['instance']->isFeatureAvailable();
} catch (NoClassException $e) {
// Feature class not found
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FRAMEWORK-FEATURE: Feature "%s"is not available due to missing feature class. Disabling feature ...', $featureName));
+ self::createDebugInstance(__CLASS__, __LINE__)->warningMessage(sprintf('FRAMEWORK-FEATURE: Feature "%s"is not available due to missing feature class. Disabling feature ...', $featureName));
}
}
// Return "cached" status
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FRAMEWORK-FEATURE: featureName=%s,isAvailable=%d - EXIT!', $featureName, intval(self::$enabledFeatures[$featureName]['is_available'])));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('FRAMEWORK-FEATURE: featureName=%s,isAvailable=%d - EXIT!', $featureName, intval(self::$enabledFeatures[$featureName]['is_available'])));
return self::$enabledFeatures[$featureName]['is_available'];
}
* @param $featureMethod Method name of the feature's class
* @param $args Any arguments that should be handled over
* @return $return Anything the feature's method has returned
+ * @throws InvalidArgumentException If a parameter has an invalid value
+ * @throws BadMethodCallException If this method has been invoked but the feature isn't available
* @throws FeatureMethodNotCallableException If the requested method cannot be called
*/
- public static function callFeature ($featureName, $featureMethod, array $args = NULL) {
- /*
- * Please make sure that isFeatureAvailable() has been called and it has
- * returned true before calling this method.
- */
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FRAMEWORK-FEATURE: featureName=%s,featureMethod=%s,args[]=%s - CALLED!', $featureName, $featureMethod, gettype($args)));
- assert(self::isFeatureAvailable($featureName));
+ public static function callFeature (string $featureName, string $featureMethod, array $args = NULL) {
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('FRAMEWORK-FEATURE: featureName=%s,featureMethod=%s,args[]=%s - CALLED!', $featureName, $featureMethod, gettype($args)));
+ if (empty($featureName)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "featureName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($featureMethod)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "featureMethod" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (!self::isFeatureAvailable($featureName)) {
+ // Throw BMCE
+ throw new BadMethodCallException(sprintf('Feature "%s" is not available but method "%s" should be invoked.', $featureName, $featureMethod), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
+ }
// Array for call-back
$callable = array(
$return = call_user_func_array($callable, $args);
// Return any returned value
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FRAMEWORK-FEATURE: return[]=%s - EXIT!', gettype($return)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('FRAMEWORK-FEATURE: return[]=%s - EXIT!', gettype($return)));
return $return;
}
// Import framework stuff
use Org\Mxchange\CoreFramework\Feature\BaseFeature;
use Org\Mxchange\CoreFramework\Feature\Feature;
+use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
/**
* A FUSE feature class
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
$isAvailable = false;
// Unfinished:
- $this->partialStub('Please implement this method.');
+ DebugMiddleware::getSelfInstance()->partialStub('Please implement this method.');
// Return status
return $isAvailable;
use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
use Org\Mxchange\CoreFramework\Filesystem\File\BaseAbstractFile;
use Org\Mxchange\CoreFramework\Filesystem\FilePointer;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
+use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
use Org\Mxchange\CoreFramework\Traits\Index\IndexableTrait;
use Org\Mxchange\CoreFramework\Traits\Stack\StackableTrait;
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
*/
protected function __construct (string $className) {
// Call parent constructor
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: className=%s - CALLED!', $className));
parent::__construct($className);
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('FRAMEWORK-DIRECTORY-POINTER: EXIT!');
}
/**
* @return void
*/
private function setBackBuffer (string $backBuffer) {
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: Setting backBuffer(%d)=%s - CALLED!', strlen($backBuffer), $backBuffer));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: Setting backBuffer(%d)=%s - CALLED!', strlen($backBuffer), $backBuffer));
$this->backBuffer = $backBuffer;
}
* @return $backBuffer Characters "stored" in back-buffer
*/
private function getBackBuffer () {
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: Getting this->backBuffer(%d)=%s - CALLED!', strlen($this->backBuffer), $this->backBuffer));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: Getting this->backBuffer(%d)=%s - CALLED!', strlen($this->backBuffer), $this->backBuffer));
return $this->backBuffer;
}
* @return void
*/
private function setCurrentBlock (string $currentBlock) {
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: Setting currentBlock(%d)=%s - CALLED!', strlen($currentBlock), $currentBlock));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: Setting currentBlock(%d)=%s - CALLED!', strlen($currentBlock), $currentBlock));
$this->currentBlock = $currentBlock;
}
* @return $current Currently read data
*/
public function getCurrentBlock () {
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: Getting this->currentBlock(%d)=%s - CALLED!', strlen($this->currentBlock), $this->currentBlock));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: Getting this->currentBlock(%d)=%s - CALLED!', strlen($this->currentBlock), $this->currentBlock));
return $this->currentBlock;
}
* @return $totalEntries Size of file header
*/
public final function getHeaderSize () {
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: Getting this->headerSize=%d - CALLED!', $this->headerSize));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: Getting this->headerSize=%d - CALLED!', $this->headerSize));
return $this->headerSize;
}
* @return void
*/
public final function setHeaderSize (int $headerSize) {
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: Setting headerSize=%d - CALLED!', $headerSize));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: Setting headerSize=%d - CALLED!', $headerSize));
$this->headerSize = $headerSize;
}
* @return $seekPosition Current seek position (stored here in object)
*/
public final function getSeekPosition () {
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: Getting this->seekPosition=%d - CALLED!', $this->seekPosition));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: Getting this->seekPosition=%d - CALLED!', $this->seekPosition));
return $this->seekPosition;
}
* @return void
*/
protected final function setSeekPosition (int $seekPosition) {
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: Setting seekPosition=%d - CALLED!', $seekPosition));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: Setting seekPosition=%d - CALLED!', $seekPosition));
$this->seekPosition = $seekPosition;
}
*/
public function isFileGapsOnly () {
// Count every gap
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-BINARY-FILE: CALLED!');
$gapsSize = 0;
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: this->gaps()=%d', count($this->gaps)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-BINARY-FILE: this->gaps()=%d', count($this->gaps)));
foreach ($this->gaps as $gap) {
// Calculate size of found gap: end-start including both
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: gap[%s]=%d,ga[%s]=%d', BinaryFile::GAPS_INDEX_START, $gap[BinaryFile::GAPS_INDEX_START], BinaryFile::GAPS_INDEX_END, $gap[BinaryFile::GAPS_INDEX_END]));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-BINARY-FILE: gap[%s]=%d,ga[%s]=%d', BinaryFile::GAPS_INDEX_START, $gap[BinaryFile::GAPS_INDEX_START], BinaryFile::GAPS_INDEX_END, $gap[BinaryFile::GAPS_INDEX_END]));
$gapsSize += ($gap[BinaryFile::GAPS_INDEX_END] - $gap[BinaryFile::GAPS_INDEX_START]);
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: gapsSize=%d', $gapsSize));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-BINARY-FILE: gapsSize=%d', $gapsSize));
}
// Total gap size + header size + 1 must be same as file size
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: gapsSize=%d,this->headerSize=%d,this->fileSize=%d', $gapsSize, $this->getHeaderSize(), $this->getFileSize()));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-BINARY-FILE: gapsSize=%d,this->headerSize=%d,this->fileSize=%d', $gapsSize, $this->getHeaderSize(), $this->getFileSize()));
$determinedFileSize = ($gapsSize + $this->getHeaderSize() + 1);
// Should not be more!
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: determinedFileSize=%d,this->fileSize=%d', $determinedFileSize, $this->getFileSize()));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-BINARY-FILE: determinedFileSize=%d,this->fileSize=%d', $determinedFileSize, $this->getFileSize()));
if ($determinedFileSize > $this->getFileSize()) {
// Should not happen
throw new OutOfBoundsException(sprintf('determinedFileSize=%d is larger than this->fileSize=%d', $determinedFileSize, $this->getFileSize()));
$isGapsOnly = ($determinedFileSize == $this->getFileSize());
// Return flag
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: isGapsOnly=%d - EXIT!', intval($isGapsOnly)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: isGapsOnly=%d - EXIT!', intval($isGapsOnly)));
return $isGapsOnly;
}
*/
private function markFileGapsOnly (string $type, int $minimumBlockLength) {
// Is config cache there?
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: type=%s,minimumBlockLength=%d - CALLED!', $type, $minimumBlockLength));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: type=%s,minimumBlockLength=%d - CALLED!', $type, $minimumBlockLength));
if (!isset(self::$configCache[$type . '_pre_allocate_count'])) {
// Then set it
self::$configCache[$type . '_pre_allocate_count'] = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry($type . '_pre_allocate_count');
}
// Very simple to do ...
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-BINARY-FILE: self:configCache[%s_pre_allocate_count]=%d', $type, self::$configCache[$type . '_pre_allocate_count']));
for ($idx = 0; $idx < self::$configCache[$type . '_pre_allocate_count']; $idx++) {
// Calculate start/end positions
$startPosition = $idx * $minimumBlockLength;
$endPosition = $idx * $minimumBlockLength + $minimumBlockLength;
// Mark start and end position as gap
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: Calling this->addGap(%d, %d) ...', $startPosition, $endPosition));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: Invoking this->addGap(%d, %d) ...', $startPosition, $endPosition));
$this->addGap($startPosition, $endPosition);
}
// Trace message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-BINARY-FILE: EXIT!');
}
/**
*/
private function addGap(int $startPosition, int $endPosition) {
// Push to gaps array
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: startPosition=%d,endPosition=%d - CALLED!', $startPosition, $endPosition));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: startPosition=%d,endPosition=%d - CALLED!', $startPosition, $endPosition));
array_push($this->gaps, [
BinaryFile::GAPS_INDEX_START => $startPosition,
BinaryFile::GAPS_INDEX_END => $endPosition,
]);
// Trace message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-BINARY-FILE: EXIT!');
}
/**
*/
private function initBackBuffer () {
// Simply call the setter
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-BINARY-FILE: CALLED!');
$this->setBackBuffer('');
// Trace message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-BINARY-FILE: EXIT!');
}
/**
*/
protected function rewindUpdateSeekPosition (bool $flushHeader = false) {
// Seek to beginning of file
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: flushHeader=%d - CALLED!', intval($flushHeader)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: flushHeader=%d - CALLED!', intval($flushHeader)));
$this->rewind();
// And update seek position ...
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: Calling this->updateSeekPosition() ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-BINARY-FILE: Invoking this->updateSeekPosition() ...');
$this->updateSeekPosition();
// Flush headers?
if ($flushHeader) {
// ... to write it back into the file
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: Calling this->flushFileHeader() ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-BINARY-FILE: Invoking this->flushFileHeader() ...');
$this->flushFileHeader();
}
// Trace message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-BINARY-FILE: EXIT!');
}
/**
*/
protected function seekToOldPosition () {
// Seek to currently ("old") saved position
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-BINARY-FILE: CALLED!');
$this->seek($this->determineSeekPosition());
// Trace message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-BINARY-FILE: EXIT!');
}
/**
*/
protected function initFile (SplFileInfo $fileInfoInstance) {
// Get a file i/o pointer instance
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: fileInfoInstance[%s]=%s - CALLED!', get_class($fileInfoInstance), $fileInfoInstance));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: fileInfoInstance[%s]=%s - CALLED!', get_class($fileInfoInstance), $fileInfoInstance));
$pointerInstance = ObjectFactory::createObjectByConfiguredName('file_raw_input_output_class', array($fileInfoInstance));
// ... and set it here
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: Setting pointerInstance=%s ...', $pointerInstance->__toString()));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-BINARY-FILE: Setting pointerInstance=%s ...', $pointerInstance->__toString()));
$this->setPointerInstance($pointerInstance);
// Trace message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-BINARY-FILE: EXIT!');
}
/**
*/
protected function markCurrentBlockAsEmpty (int $length) {
// Validate parameter
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: length=%d - CALLED!', $length));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: length=%d - CALLED!', $length));
if ($length < 1) {
// Length cannot below one
- throw new InvalidArgumentException(sprintf('length=%d is not valid', $length));
+ throw new InvalidArgumentException(sprintf('length=%d is not valid', $length), FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
}
// Get current seek position
$currentPosition = $this->determineSeekPosition();
// Now add it as gap entry
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: Calling this->addGap(%d, %d) ..', ($currentPosition - $length), $currentPosition));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: Invoking this->addGap(%d, %d) ..', ($currentPosition - $length), $currentPosition));
$this->addGap(($currentPosition - $length), $currentPosition);
// Trace message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-BINARY-FILE: EXIT!');
}
/**
*/
public function initCountersGapsArray () {
// Init counter and seek position to header size
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: Calling this->determineSeekPosition() - CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-BINARY-FILE: Invoking this->determineSeekPosition() - CALLED!');
$seekPosition = $this->getSeekPosition();
// Set counter
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: seekPosition=%d', $seekPosition));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-BINARY-FILE: seekPosition=%d', $seekPosition));
$this->setCounter(0);
// Get header size
$headerSize = $this->getHeaderSize();
// Set it
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: Setting this->seekPosition=%d ...', $headerSize));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-BINARY-FILE: Setting this->seekPosition=%d ...', $headerSize));
$this->setSeekPosition($headerSize);
// Init arrays
$this->damagedEntries = [];
// Seek back to old position
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: Calling this->seek(%d) ...', $seekPosition));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: Invoking this->seek(%d) ...', $seekPosition));
$this->seek($seekPosition);
// Trace message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-BINARY-FILE: EXIT!');
}
/**
*/
public function updateSeekPosition () {
// Get key (= seek position)
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-BINARY-FILE: CALLED!');
$seekPosition = $this->determineSeekPosition();
// And set it here
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: seekPosition=%d', $seekPosition));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-BINARY-FILE: seekPosition=%d', $seekPosition));
$this->setSeekPosition($seekPosition);
// Trace message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-BINARY-FILE: EXIT!');
}
/**
*/
public static function isBlockSeparatorFound (string $str) {
// Validate parameter
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: str=%s - CALLED!', $str));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: str=%s - CALLED!', $str));
if (empty($str)) {
// Throw IAE
- throw new InvalidArgumentException('Parameter "str" is empty');
+ throw new InvalidArgumentException('Parameter "str" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
}
// Determine it
$isFound = (strpos($str, chr(BinaryFile::SEPARATOR_ENTRIES)) !== false);
// Return result
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: isFound=%d - EXIT!', intval($isFound)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: isFound=%d - EXIT!', intval($isFound)));
return $isFound;
}
*/
public function writeData (int $seekPosition, string $data, bool $flushHeader = true) {
// Validate parameter
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: seekPosition=%s,data()=%d,flushHeader=%d - CALLED!', $seekPosition, strlen($data), intval($flushHeader)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: seekPosition=%s,data()=%d,flushHeader=%d - CALLED!', $seekPosition, strlen($data), intval($flushHeader)));
if ($seekPosition < 0) {
// Invalid seek position
throw new OutOfBoundsException(sprintf('seekPosition=%d is not valid', $seekPosition));
} elseif (empty($data)) {
// Empty data is invalid, too
- throw new InvalidArgumentException('Parameter "data" is empty');
+ throw new InvalidArgumentException('Parameter "data" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
}
// Write data at given position
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: Calling this->writeAtPosition(%d,%s) ...', $seekPosition, $data));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: Invoking this->writeAtPosition(%d,%s) ...', $seekPosition, $data));
$this->writeAtPosition($seekPosition, $data);
// Increment counter
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: Calling this->incrementCounter() ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-BINARY-FILE: Invoking this->incrementCounter() ...');
$this->incrementCounter();
// Update seek position
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: Calling this->updateSeekPosition() ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-BINARY-FILE: Invoking this->updateSeekPosition() ...');
$this->updateSeekPosition();
// Flush the header?
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: flushHeader=%d', intval($flushHeader)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-BINARY-FILE: flushHeader=%d', intval($flushHeader)));
if ($flushHeader === true) {
// Flush header
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: Calling this->flushFileHeader() ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-BINARY-FILE: Invoking this->flushFileHeader() ...');
$this->flushFileHeader();
// Seek to old position
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: Calling this->seekToOldPosition() ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-BINARY-FILE: Invoking this->seekToOldPosition() ...');
$this->seekToOldPosition();
}
// Trace message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-BINARY-FILE: EXIT!');
}
/**
*/
public function writeAtPosition (int $seekPosition, string $dataStream) {
// Validate parameter
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: seekPosition=%d,dataStream(%d)=%s - CALLED!', $seekPosition, strlen($dataStream), $dataStream));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: seekPosition=%d,dataStream(%d)=%s - CALLED!', $seekPosition, strlen($dataStream), $dataStream));
if ($seekPosition < 0) {
// Invalid seek position
throw new OutOfBoundsException(sprintf('seekPosition=%d is not valid.', $seekPosition));
} elseif (empty($dataStream)) {
// Empty dataStream
- throw new InvalidArgumentException('Parameter "dataStream" is empty');
+ throw new InvalidArgumentException('Parameter "dataStream" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
}
// Call pointer's method
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: Calling this->pointerInstance->writeAtPosition(%d, %s) ...', $seekPosition, $dataStream));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: Invoking this->pointerInstance->writeAtPosition(%d, %s) ...', $seekPosition, $dataStream));
$status = $this->getPointerInstance()->writeAtPosition($seekPosition, $dataStream);
// Return status
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: status[%s]=%d - EXIT!', gettype($status), $status));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: status[%s]=%d - EXIT!', gettype($status), $status));
return $status;
}
*/
public function isFileHeaderInitialized () {
// Default is not initialized
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-BINARY-FILE: CALLED!');
$isInitialized = false;
// Is the file initialized?
$this->rewind();
// Read file header
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: Calling this->readFileHeader() ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-BINARY-FILE: Invoking this->readFileHeader() ...');
$this->readFileHeader();
// Get header count
$headerCount = count($this->getHeader());
// The above method does already check the header
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: headerCount=%d', $headerCount));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-BINARY-FILE: headerCount=%d', $headerCount));
$isInitialized = ($headerCount > 0);
}
// Return result
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: isInitialized=%d - EXIT!', intval($isInitialized)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: isInitialized=%d - EXIT!', intval($isInitialized)));
return $isInitialized;
}
*/
public function isFileInitialized () {
// Get it from iterator which holds the pointer instance. If false is returned
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-BINARY-FILE: CALLED!');
$fileSize = $this->size();
/*
* The returned file size should not be false or NULL as this means
* that the pointer class does not work correctly.
*/
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: fileSize[%s]=%d', gettype($fileSize), $fileSize));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-BINARY-FILE: fileSize[%s]=%d', gettype($fileSize), $fileSize));
if (!is_int($fileSize)) {
// Bad file?
- throw new UnexpectedValueException(sprintf('fileSize[]=%s is unexpected', gettype($fileSize)));
+ throw new UnexpectedValueException(sprintf('fileSize[]=%s is unexpected', gettype($fileSize)), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
}
// Is more than 0 returned?
$isInitialized = ($fileSize > 0);
// Return result
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: isInitialized=%d - EXIT!', intval($isInitialized)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: isInitialized=%d - EXIT!', intval($isInitialized)));
return $isInitialized;
}
*/
public function createFileHeader () {
// The file's header should not be initialized here
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-BINARY-FILE: CALLED!');
if ($this->isFileHeaderInitialized()) {
// Bad method call
//* DEBUG-DIE: */ ApplicationEntryPoint::exitApplication(sprintf('[%s:%d]: this=%s', __METHOD__, __LINE__, print_r($this, TRUE)));
- throw new BadMethodCallException('File header is already initialized but method called');
+ throw new BadMethodCallException('File header is already initialized but method called', FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
}
// Simple flush file header which will create it.
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: Calling this->flushFileHeader() ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-BINARY-FILE: Invoking this->flushFileHeader() ...');
$this->flushFileHeader();
// Rewind seek position (to beginning of file) and update/flush file header
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: Calling this->rewindUpdateSeekPosition() ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-BINARY-FILE: Invoking this->rewindUpdateSeekPosition() ...');
$this->rewindUpdateSeekPosition();
// Trace message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-BINARY-FILE: EXIT!');
}
/**
*/
public function determineSeekPosition () {
// Call pointer instance
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-BINARY-FILE: CALLED!');
$seekPosition = $this->getPointerInstance()->determineSeekPosition();
// Return position
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: seekPosition=%d - EXIT!', $seekPosition));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: seekPosition=%d - EXIT!', $seekPosition));
return $seekPosition;
}
*/
public function seek (int $offset, int $whence = SEEK_SET) {
// Validate parameter
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: offset=%d,whence=%d - CALLED!', $offset, $whence));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: offset=%d,whence=%d - CALLED!', $offset, $whence));
if ($offset < 0) {
// No offset is smaller than zero
throw new OutOfBoundsException(sprintf('offset=%d is not valid', $offset));
$status = $this->getPointerInstance()->seek($offset, $whence);
// Return status
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: status[%s]=%d - EXIT!', gettype($status), $status));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: status[%s]=%d - EXIT!', gettype($status), $status));
return $status;
}
*/
public function read (int $bytes = 0) {
// Validate parameter
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: bytes=%d - CALLED!', $bytes));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: bytes=%d - CALLED!', $bytes));
if ($bytes < 0) {
// Throw exception
throw new OutOfBoundsException(sprintf('bytes=%d is not valid', $bytes));
}
// Call pointer instance
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: Calling this->pointerInstance->read(%d) ...', $bytes));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: Invoking this->pointerInstance->read(%d) ...', $bytes));
$data = $this->getPointerInstance()->read($bytes);
// Update seek position
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: Calling this->updateSeekPosition() ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-BINARY-FILE: Invoking this->updateSeekPosition() ...');
$this->updateSeekPosition();
// Return data
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: data[%s]=%s - EXIT!', gettype($data), $data));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: data[%s]=%s - EXIT!', gettype($data), $data));
return $data;
}
*/
public function rewind () {
// Call pointer instance
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-BINARY-FILE: CALLED!');
$this->getPointerInstance()->rewind();
// Trace message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-BINARY-FILE: EXIT!');
}
/**
*/
public function analyzeFileStructure () {
// Make sure the file is initialized
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-BINARY-FILE: CALLED!');
if (!$this->isFileInitialized()) {
// Bad method call
- throw new BadMethodCallException('Method called but file is not initialized.');
+ throw new BadMethodCallException('Method called but file is not initialized.', FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
}
// Init counters and gaps array
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: Calling this->initCounterGapsArrays() ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-BINARY-FILE: Invoking this->initCounterGapsArrays() ...');
$this->initCountersGapsArray();
// Output message (as this may take some time)
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('Analyzing file structure ... (this may take some time)'));
+ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('Analyzing file structure ... (this may take some time)'));
// First Seek to right after file header
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: Calling this->seek(%d) ...', $this->getHeaderSize() + 1));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: Invoking this->seek(%d) ...', $this->getHeaderSize() + 1));
$this->seek($this->getHeaderSize() + 1);
// Then try to load all entries
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: this->seekPosition=%d, looping through file ...', $this->getSeekPosition()));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-BINARY-FILE: this->seekPosition=%d, looping through file ...', $this->getSeekPosition()));
while ($this->isValid()) {
// Get current entry
$current = $this->getCurrentBlock();
// Go to next entry
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: current=%s, calling this->readNextBlock() ...', $current));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: current=%s, Invoking this->readNextBlock() ...', $current));
$this->readNextBlock();
/*
* If the block is empty, maybe the whole file is? This could mean
* that the file has been pre-allocated.
*/
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: current(%d)[]=%s', strlen($current), gettype($current)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-BINARY-FILE: current(%d)[]=%s', strlen($current), gettype($current)));
if (empty(trim($current, chr(0)))) {
// Then skip this part
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: current[]=%s is empty - CONTINUE!', gettype($current)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-BINARY-FILE: current[]=%s is empty - CONTINUE!', gettype($current)));
continue;
}
// Handle current record
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: current(%d)[%s]=%s', strlen($current), gettype($current), $current));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-BINARY-FILE: current(%d)[%s]=%s', strlen($current), gettype($current), $current));
}
// If the last read block is empty, check gaps
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: current()=%d', strlen($current)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-BINARY-FILE: current()=%d', strlen($current)));
if (empty(trim($current, chr(0)))) {
// Output message
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: Found a total of %d gaps.', count($this->gaps)));
+ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-BINARY-FILE: Found a total of %d gaps.', count($this->gaps)));
// Check gaps, if the whole file is empty.
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: Calling this->isFileGapsOnly() ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-BINARY-FILE: Invoking this->isFileGapsOnly() ...');
if ($this->isFileGapsOnly()) {
// Only gaps, so don't continue here.
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: File is gaps-only - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('BASE-BINARY-FILE: File is gaps-only - EXIT!');
return;
}
}
* defragmentation is to far in the past, or if a "hard" limit has
* reached, run defragmentation.
*/
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: Calling this->isDefragmentationNeeded() ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-BINARY-FILE: Invoking this->isDefragmentationNeeded() ...');
if ($this->isDefragmentationNeeded()) {
// Run "defragmentation"
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: Calling this->doRunDefragmentation() ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-BINARY-FILE: Invoking this->doRunDefragmentation() ...');
$this->doRunDefragmentation();
}
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-BINARY-FILE: EXIT!');
}
/**
*/
protected function readNextBlockByLength (int $length) {
// Validate parameter
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: this->seekPosition=%d,length=%d - CALLED!', $this->getSeekPosition(), $length));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: this->seekPosition=%d,length=%d - CALLED!', $this->getSeekPosition(), $length));
if ($length < 1) {
// Throw IAE
- throw new InvalidArgumentException(sprintf('length=%d is not valid', $length));
+ throw new InvalidArgumentException(sprintf('length=%d is not valid', $length), FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
}
// Read possibly back-buffered bytes from previous call of next().
* "block" may not fit, so this loop will continue until the EOB or EOF
* has been reached whatever comes first.
*/
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: this->seekPosition=%d,data()=%d', $this->getSeekPosition(), strlen($data)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-BINARY-FILE: this->seekPosition=%d,data()=%d', $this->getSeekPosition(), strlen($data)));
while ((!$this->isEndOfFileReached()) && (empty($data) || !self::isBlockSeparatorFound($data))) {
// Then read the next possible block
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: this->seekPosition=%d, calling this->read(%d) ...', $this->getSeekPosition(), $length));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-BINARY-FILE: this->seekPosition=%d, Invoking this->read(%d) ...', $this->getSeekPosition(), $length));
$block = $this->read($length);
// Is the block empty?
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: block()=%d,length=%d', strlen($block), $length));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-BINARY-FILE: block()=%d,length=%d', strlen($block), $length));
if (strlen($block) == 0) {
// Read empty block, maybe EOF
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: this->seekPosition=%d, block is empty, maybe EOF reached - BREAK!', $this->getSeekPosition()));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-BINARY-FILE: this->seekPosition=%d, block is empty, maybe EOF reached - BREAK!', $this->getSeekPosition()));
break;
} elseif (empty(trim($block, chr(0)))) {
// Mark it as empty
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: this->seekPosition=%d, calling this->markCurrentBlockAsEmpty(%d) ...', $this->getSeekPosition(), $length));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-BINARY-FILE: this->seekPosition=%d, Invoking this->markCurrentBlockAsEmpty(%d) ...', $this->getSeekPosition(), $length));
$this->markCurrentBlockAsEmpty($length);
}
$data .= $block;
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: this->seekPosition=%d,data()=%d', $this->getSeekPosition(), strlen($data)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-BINARY-FILE: this->seekPosition=%d,data()=%d', $this->getSeekPosition(), strlen($data)));
}
/*
* Init back-buffer which is the data that has been found beyond the
* separator.
*/
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: Calling this->initBackBuffer(), clearing this->currentBlock ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-BINARY-FILE: Invoking this->initBackBuffer(), clearing this->currentBlock ...');
$this->initBackBuffer();
$this->setCurrentBlock('');
// Is $data empty?
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: data(%d)=%s', strlen($data), $data));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-BINARY-FILE: data(%d)=%s', strlen($data), $data));
if (empty(trim($data, chr(0)))) {
// Yes, maybe whole file was ...
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: this->seekPosition=%d, maybe empty file found - EXIT!', $this->getSeekPosition()));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-BINARY-FILE: this->seekPosition=%d, maybe empty file found - EXIT!', $this->getSeekPosition()));
return;
}
$dataArray = explode(chr(BinaryFile::SEPARATOR_ENTRIES), $data);
// Left part is the actual block, right one the back-buffer data, if found
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: dataArray()=%d', count($dataArray)));
- //* PRINTR-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: dataArray=%s', print_r($dataArray, true)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-BINARY-FILE: dataArray()=%d', count($dataArray)));
+ //* PRINTR-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-BINARY-FILE: dataArray=%s', print_r($dataArray, true)));
$this->setCurrentBlock($dataArray[0]);
// Is back buffere data found?
if (isset($dataArray[1]) && !empty(trim($dataArray[1], chr(0)))) {
// Set back buffer
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: Setting this->backBuffer=%s ...', $dataArray[1]));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-BINARY-FILE: Setting this->backBuffer=%s ...', $dataArray[1]));
$this->setBackBuffer($dataArray[1]);
}
// Trace message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-BINARY-FILE: EXIT!');
}
/**
* @param $type Type of the file
* @return void
* @throws InvalidArgumentException If a parameter is empty
- * @throws BadMethodCallException If this->stackInstance is not properly set
*/
protected function preAllocateFileByTypeLength (string $type, int $minimumBlockLength) {
// Is it enabled?
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: type=%s,minimumBlockLength=%d - CALLED!', $type, $minimumBlockLength));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: type=%s,minimumBlockLength=%d - CALLED!', $type, $minimumBlockLength));
if (empty($type)) {
// Empty type
- throw new InvalidArgumentException('Parameter "type" is empty');
+ throw new InvalidArgumentException('Parameter "type" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif ($minimumBlockLength < 1) {
// Invalid block length
- throw new InvalidArgumentException(sprintf('Parameter minimumBlockLength=%d is not valid', $minimumBlockLength));
- } elseif (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry($type . '_pre_allocate_enabled') != 'Y') {
+ throw new InvalidArgumentException(sprintf('Parameter minimumBlockLength=%d is not valid', $minimumBlockLength), FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (!FrameworkBootstrap::getConfigurationInstance()->isEnabled($type . '_pre_allocate')) {
// Don't continue here.
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: Not pre-allocating file.'));
+ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-BINARY-FILE: Not pre-allocating file. - EXIT!');
return;
}
$fileSize = $this->getFileSize();
// Calulcate seek position
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: minimumBlockLength=%d,fileSize=%d', $minimumBlockLength, $fileSize));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-BINARY-FILE: minimumBlockLength=%d,fileSize=%d', $minimumBlockLength, $fileSize));
$seekPosition = $this->getHeaderSize() + $minimumBlockLength * FrameworkBootstrap::getConfigurationInstance()->getConfigEntry($type . '_pre_allocate_count') + $fileSize ;
// Now simply write a NUL there. This will pre-allocate the file.
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: Calling this->writeAtPosition(%d,NUL) ...', $seekPosition));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: Invoking this->writeAtPosition(%d,NUL) ...', $seekPosition));
$this->writeAtPosition($seekPosition, chr(0));
// Is the seek position zero?
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: fileSize=%d', $fileSize));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-BINARY-FILE: fileSize=%d', $fileSize));
if ($fileSize == 0) {
// Mark file as gaps-only
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: Calling this->markGapsOnly(%s,%d) ...', $type, $minimumBlockLength));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: Invoking this->markGapsOnly(%s,%d) ...', $type, $minimumBlockLength));
$this->markFileGapsOnly($type, $minimumBlockLength);
} else {
// Analyze file structure
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: Calling this->analyzeFileStructure() ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-BINARY-FILE: Invoking this->analyzeFileStructure() ...');
$this->analyzeFileStructure();
}
// Rewind seek position
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: Calling this->rewind() ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-BINARY-FILE: Invoking this->rewind() ...');
$this->rewind();
// Trace message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-BINARY-FILE: EXIT!');
}
/**
*/
protected function isValidByLength (int $length) {
// Validate parameter
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: length=%d - CALLED!', $length));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: length=%d - CALLED!', $length));
if ($length < 1) {
// Throw IAE
- throw new InvalidArgumentException(sprintf('Parameter length=%d is not valid', $length));
+ throw new InvalidArgumentException(sprintf('Parameter length=%d is not valid', $length), FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
}
// Get current seek position
$seekPosition = $this->determineSeekPosition();
// Then try to read it
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: seekPosition=%d', $seekPosition));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-BINARY-FILE: seekPosition=%d', $seekPosition));
$data = $this->read($length);
// If some bytes could be read, all is fine
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: data[%s]()=%d', gettype($data), strlen($data)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-BINARY-FILE: data[%s]()=%d', gettype($data), strlen($data)));
$isValid = ((is_string($data)) && (strlen($data) > 0));
// Get header size
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: isValid=%d', intval($isValid)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-BINARY-FILE: isValid=%d', intval($isValid)));
$headerSize = $this->getHeaderSize();
// Is the seek position at or beyond the header?
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: seekPosition=%d,headerSize=%d', $seekPosition, $headerSize));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-BINARY-FILE: seekPosition=%d,headerSize=%d', $seekPosition, $headerSize));
if ($seekPosition >= $headerSize) {
// Seek back to old position
$isValid = ($isValid && $this->seek($seekPosition) === 0);
}
// Return result
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: isValid=%d - EXIT!', intval($isValid)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: isValid=%d - EXIT!', intval($isValid)));
return $isValid;
}
*/
public function searchNextGap (int $length) {
// If the file is only gaps, no need to seek
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: length=%d - CALLED!', $length));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: length=%d - CALLED!', $length));
if ($length <= 0) {
// Throw IAE
- throw new InvalidArgumentException(sprintf('length=%d is not valid', $length));
+ throw new InvalidArgumentException(sprintf('length=%d is not valid', $length), FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif ($this->isFileGapsOnly()) {
/*
* The first empty block is the 2nd one right after the header, so
$seekPosition = ($this->getHeaderSize() + 2);
// Return position
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: seekPosition=%d - EXIT!', $seekPosition));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-BINARY-FILE: seekPosition=%d - EXIT!', $seekPosition));
return $seekPosition;
}
// @TODO Unfinished
- $this->partialStub('length=' . $length);
+ DebugMiddleware::getSelfInstance()->partialStub('length=' . $length);
}
}
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
use Org\Mxchange\CoreFramework\Filesystem\File\BaseBinaryFile;
use Org\Mxchange\CoreFramework\Filesystem\Index\IndexableFile;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
use Org\Mxchange\CoreFramework\Index\Indexable;
use Org\Mxchange\CoreFramework\Utils\Crypto\CryptoUtils;
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
*/
public final static function createIndexFile (SplFileInfo $fileInfoInstance, Indexable $indexInstance) {
// Get a new instance
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('INDEX-FILE: fileInfoInstance[%s]=%s,indexInstance=%s - CALLED!', get_class($fileInfoInstance), $fileInfoInstance, $indexInstance->__toString()));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('INDEX-FILE: fileInfoInstance[%s]=%s,indexInstance=%s - CALLED!', get_class($fileInfoInstance), $fileInfoInstance, $indexInstance->__toString()));
$indexFileInstance = new IndexFile();
// Set file instance here for callbacks
$indexFileInstance->initCountersGapsArray();
// Return the prepared instance
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('INDEX-FILE: indexFileInstance=%s - EXIT!', $indexFileInstance->__toString()));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('INDEX-FILE: indexFileInstance=%s - EXIT!', $indexFileInstance->__toString()));
return $indexFileInstance;
}
*/
public function flushFileHeader () {
// Validate call
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('INDEX-FILE: CALLED!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('INDEX-FILE: CALLED!');
if (!($this->getIndexInstance() instanceof Indexable)) {
// Index instance not set
throw new BadMethodCallException('this->indexInstance[] is not properly set.');
}
// Call block instance
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('INDEX-FILE: Calling this->indexInstance->flushFileHeader() ...');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('INDEX-FILE: Invoking this->indexInstance->flushFileHeader() ...');
$this->getIndexInstance()->flushFileHeader();
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('INDEX-FILE: EXIT!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('INDEX-FILE: EXIT!');
}
/**
*/
public function preAllocateFile (string $type) {
// Is it enabled?
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('INDEX-FILE: type=%s - CALLED!', $type));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('INDEX-FILE: type=%s - CALLED!', $type));
if (empty($type)) {
// Empty type
- throw new InvalidArgumentException('Parameter "type" is empty');
+ throw new InvalidArgumentException('Parameter "type" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif (!($this->getIndexInstance() instanceof Indexable)) {
// Index instance not set
throw new BadMethodCallException('this->indexInstance[] is not properly set.');
}
// Message to user
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('INDEX-FILE: Pre-allocating file ...');
+ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('INDEX-FILE: Pre-allocating file ...');
// Calculate minimum block length
$minimumBlockLength = $this->getIndexInstance()->calculateMinimumBlockLength();
// Call protected method
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('INDEX-FILE: Invoking this->preAllocateFileByTypeLength(%s,%d) ...', $type, $minimumBlockLength));
$this->preAllocateFileByTypeLength($type, $minimumBlockLength);
// Trace message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('INDEX-FILE: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('INDEX-FILE: EXIT!');
}
/**
* This method will return true if an emptied (nulled) entry has been found.
*
* @return $isValid Whether the next entry is valid
- * @throws UnexpectedValueException If some value is not expected
* @throws BadMethodCallException If this->indexInstance is not properly set
*/
public function isValid () {
// Validate call
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('INDEX-FILE: CALLED!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('INDEX-FILE: CALLED!');
if (!($this->getIndexInstance() instanceof Indexable)) {
// Index instance not set
throw new BadMethodCallException('this->indexInstance[] is not properly set.');
}
// Get length from index
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('INDEX-FILE: Calling this->indexInstance->calculateMinimumBlockLength() ...');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('INDEX-FILE: Invoking this->indexInstance->calculateMinimumBlockLength() ...');
$length = $this->getIndexInstance()->calculateMinimumBlockLength();
// Call protected method
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('INDEX-FILE: Calling this->isValidByLength(%d) ...', $length));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('INDEX-FILE: Invoking this->isValidByLength(%d) ...', $length));
$isValid = $this->isValidByLength($length);
// Return result
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('INDEX-FILE: isValid=%d - EXIT!', intval($isValid)));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('INDEX-FILE: isValid=%d - EXIT!', intval($isValid)));
return $isValid;
}
*/
protected function readNextBlock () {
// First calculate minimum block length
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('INDEX-FILE: this->seekPosition=%d - CALLED!', $this->getSeekPosition()));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('INDEX-FILE: this->seekPosition=%d - CALLED!', $this->getSeekPosition()));
$length = $this->getIndexInstance()->calculateMinimumBlockLength();
// Call protected method
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('INDEX-FILE: Calling parent::readNextBlockByLength(%d) ...', $length));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('INDEX-FILE: Invoking parent::readNextBlockByLength(%d) ...', $length));
parent::readNextBlockByLength($length);
// Trace message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('INDEX-FILE: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('INDEX-FILE: EXIT!');
}
/**
*/
public function readFileHeader () {
// Call index class' method
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('INDEX-FILE: Calling this->indexInstance->readIndexHeader() - CALLED!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('INDEX-FILE: Invoking this->indexInstance->readIndexHeader() - CALLED!');
$this->getIndexInstance()->readIndexHeader();
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('INDEX-FILE: EXIT!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('INDEX-FILE: EXIT!');
}
/**
*/
public function writeValueToFile (string $stackName, $value) {
// Validate parameter
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('INDEX-FILE: stackName=%s,value[]=%s - CALLED!', $stackName, gettype($value)));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('INDEX-FILE: stackName=%s,value[]=%s - CALLED!', $stackName, gettype($value)));
if (empty($stackName)) {
// Throw IAE
- throw new InvalidArgumentException('Parameter "stackName" is empty');
+ throw new InvalidArgumentException('Parameter "stackName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif (is_object($value) || is_resource($value)) {
// Not wanted here
throw new InvalidArgumentException(sprintf('value[]=%s is not stackable in files', gettype($value)));
}
// Encode/convert the value into a "binary format"
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('INDEX-FILE: Invoking StringUtils::encodeData(value[]=%s) ...', gettype($value)));
$encoded = StringUtils::encodeData($value);
// Get a strong hash for the "encoded" data
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('INDEX-FILE: encoded=%s', $encoded));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('INDEX-FILE: encoded(%d)=%s', strlen($encoded), $encoded));
$hash = CryptoUtils::hash($encoded);
// Then write it to the next free gap
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('INDEX-FILE: hash=%s', $hash));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('INDEX-FILE: hash=%s', $hash));
$data = $this->getIndexInstance()->writeDataToFreeGap($stackName, $hash, $encoded);
// Return info
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('INDEX-FILE: data[]=%s - EXIT!', gettype($data)));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('INDEX-FILE: data[]=%s - EXIT!', gettype($data)));
return $data;
}
* @throws UnsupportedOperationException If this method is called
*/
public function writeDataToFreeGap (string $stackName, string $hash, string $encoded) {
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('INDEX-FILE: stackName=' . $stackName . ',hash=' . $hash . ',encoded()=' . strlen($encoded));
- throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('INDEX-FILE: stackName=' . $stackName . ',hash=' . $hash . ',encoded()=' . strlen($encoded));
+ throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
}
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
use Org\Mxchange\CoreFramework\Filesystem\Stack\FileStacker;
use Org\Mxchange\CoreFramework\Filesystem\File\BaseBinaryFile;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
use Org\Mxchange\CoreFramework\Stack\File\StackableFile;
use Org\Mxchange\CoreFramework\Utils\Crypto\CryptoUtils;
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
*/
public final static function createStackFile (SplFileInfo $infoInstance, StackableFile $stackInstance) {
// Get a new instance
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('STACK-FILE: infoInstance[%s]=%s,stackInstance=%s - CALLED!', get_class($infoInstance), $infoInstance, $stackInstance->__toString()));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('STACK-FILE: infoInstance[%s]=%s,stackInstance=%s - CALLED!', get_class($infoInstance), $infoInstance, $stackInstance->__toString()));
$stackFileInstance = new StackFile();
// Set stack instance here for callbacks
$stackFileInstance->initCountersGapsArray();
// Return the prepared instance
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('STACK-FILE: stackFileInstance=%s - EXIT!', $stackFileInstance->__toString()));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('STACK-FILE: stackFileInstance=%s - EXIT!', $stackFileInstance->__toString()));
return $stackFileInstance;
}
*/
public function flushFileHeader () {
// Validate call
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('STACK-FILE: CALLED!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('STACK-FILE: CALLED!');
if (!($this->getStackInstance() instanceof StackableFIle)) {
// Index instance not set
throw new BadMethodCallException('this->stackInstance[] is not properly set.');
}
// Call block instance
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('STACK-FILE: Calling this->indexInstance->flushFileHeader() ...');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('STACK-FILE: Invoking this->indexInstance->flushFileHeader() ...');
$this->getStackInstance()->flushFileHeader();
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('STACK-FILE: EXIT!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('STACK-FILE: EXIT!');
}
/**
*/
public function preAllocateFile (string $type) {
// Is it enabled?
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('STACK-FILE: type=%s - CALLED!', $type));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('STACK-FILE: type=%s - CALLED!', $type));
if (empty($type)) {
// Empty type
- throw new InvalidArgumentException('Parameter "type" is empty');
+ throw new InvalidArgumentException('Parameter "type" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif (!($this->getStackInstance() instanceof StackableFile) && !($this->getStackInstance() instanceof StackableFile)) {
// Index instance not set
throw new BadMethodCallException('this->stackInstance[] and this->pointerInstance are not properly set.');
}
// Message to user
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('STACK-FILE: Pre-allocating file ...');
+ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('STACK-FILE: Pre-allocating file ...');
// Calculate minimum block length and get file size
$minimumBlockLength = $this->getStackInstance()->calculateMinimumBlockLength();
$this->preAllocateFileByTypeLength($type, $minimumBlockLength);
// Trace message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('STACK-FILE: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('STACK-FILE: EXIT!');
}
/**
* This method will return true if an emptied (nulled) entry has been found.
*
* @return $isValid Whether the next entry is valid
- * @throws UnexpectedValueException If some value is not expected
* @throws BadMethodCallException If this->stackInstance is not properly set
*/
public function isValid () {
// Validate call
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('STACK-FILE: CALLED!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('STACK-FILE: CALLED!');
if (!($this->getStackInstance() instanceof StackableFile)) {
// Index instance not set
throw new BadMethodCallException('this->stackInstance[] is not properly set.');
}
// Get length from index
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('STACK-FILE: Calling this->stackInstance->calculateMinimumBlockLength() ...');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('STACK-FILE: Invoking this->stackInstance->calculateMinimumBlockLength() ...');
$length = $this->getStackInstance()->calculateMinimumBlockLength();
// Call protected method
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('STACK-FILE: Calling this->isValidByLength(%d) ...', $length));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('STACK-FILE: Invoking this->isValidByLength(%d) ...', $length));
$isValid = $this->isValidByLength($length);
// Return result
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('STACK-FILE: isValid=%d - EXIT!', intval($isValid)));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('STACK-FILE: isValid=%d - EXIT!', intval($isValid)));
return $isValid;
}
*/
public function readFileHeader () {
// Call stacke instance
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('STACK-FILE: Calling this->stackInstance->readStackHeader() - CALLED!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('STACK-FILE: Invoking this->stackInstance->readStackHeader() - CALLED!');
$this->getStackInstance()->readStackHeader();
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('STACK-FILE: EXIT!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('STACK-FILE: EXIT!');
}
/**
*/
protected function readNextBlock () {
// First calculate minimum block length
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('STACK-FILE: this->seekPosition=%d - CALLED!', $this->getSeekPosition()));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('STACK-FILE: this->seekPosition=%d - CALLED!', $this->getSeekPosition()));
$length = $this->getStackInstance()->calculateMinimumBlockLength();
// Call protected method
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('STACK-FILE: Calling parent::readNextBlockByLength(%d) ...', $length));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('STACK-FILE: Invoking parent::readNextBlockByLength(%d) ...', $length));
parent::readNextBlockByLength($length);
// Trace message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('STACK-FILE: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('STACK-FILE: EXIT!');
}
/**
*/
public function writeValueToFile (string $stackName, $value) {
// Validate parameter
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('STACK-FILE: stackName=%s,value[]=%s - CALLED!', $stackName, gettype($value)));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('STACK-FILE: stackName=%s,value[]=%s - CALLED!', $stackName, gettype($value)));
if (empty($stackName)) {
// Throw IAE
- throw new InvalidArgumentException('Parameter "stackName" is empty');
+ throw new InvalidArgumentException('Parameter "stackName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif (is_object($value) || is_resource($value)) {
// Not wanted here
throw new InvalidArgumentException(sprintf('value[]=%s is not stackable in files', gettype($value)));
}
// Encode/convert the value into a "binary format"
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('STACK-FILE: Calling StringUtils::encodeData(value[]=%s) ...', gettype($value)));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('STACK-FILE: Invoking StringUtils::encodeData(value[]=%s) ...', gettype($value)));
$encoded = StringUtils::encodeData($value);
// Get a strong hash for the "encoded" data
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('STACK-FILE: Calling CryptoUtils::hash(%s) ...', $encoded));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('STACK-FILE: Invoking CryptoUtils::hash(%s) ...', $encoded));
$hash = CryptoUtils::hash($encoded);
// Then write it to the next free gap
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('STACK-FILE: Calling this->stackInstance->writeDataToFreeGap(%s,%s,%s) ...', $stackName, $hash, $encoded));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('STACK-FILE: Invoking this->stackInstance->writeDataToFreeGap(%s,%s,%s) ...', $stackName, $hash, $encoded));
$data = $this->getStackInstance()->writeDataToFreeGap($stackName, $hash, $encoded);
// Return info
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('STACK-FILE: data[]=%s - EXIT!', gettype($data)));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('STACK-FILE: data[]=%s - EXIT!', gettype($data)));
return $data;
}
* @throws UnsupportedOperationException If this method is called
*/
public function writeDataToFreeGap (string $stackName, string $hash, string $encoded) {
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('STACK-FILE: stackName=' . $stackName . ',hash=' . $hash . ',encoded()=' . strlen($encoded));
- throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('STACK-FILE: stackName=' . $stackName . ',hash=' . $hash . ',encoded()=' . strlen($encoded));
+ throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
}
// Import framework stuff
use Org\Mxchange\CoreFramework\Filesystem\CloseableFile;
use Org\Mxchange\CoreFramework\Filesystem\FilePointer;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
+// Import SPL stuff
+use \InvalidArgumentException;
+
/**
* An abstract file class
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
*/
protected function __construct (string $className) {
// Call parent constructor
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-ABSTRACT-FILE: className=%s - CONSTRUCTED!', $className));
parent::__construct($className);
+
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-ABSTRACT-FILE: EXIT!');
}
/**
*/
protected final function unsetPointerInstance () {
// Simply invoke setter with no parameter
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-ABSTRACT-FILE: CALLED!');
$this->setPointerInstance();
+
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-ABSTRACT-FILE: EXIT!');
}
/**
*/
public final function __destruct() {
// Try to close a file
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-ABSTRACT-FILE: DESTRUCTED!');
$this->closeFile();
// Call the parent destructor
parent::__destruct();
+
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-ABSTRACT-FILE: EXIT!');
}
/**
*/
public function getFileSize () {
// Call pointer instanze
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-ABSTRACT-FILE: CALLED!');
return $this->getPointerInstance()->getFileSize();
}
*/
public final function getCounter () {
// Get it
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-ABSTRACT-FILE: Getting this->totalEntries=%d ... - CALLED!', $this->totalEntries));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-ABSTRACT-FILE: Getting this->totalEntries=%d ... - CALLED!', $this->totalEntries));
return $this->totalEntries;
}
*/
protected final function setCounter (int $counter) {
// Set it
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-ABSTRACT-FILE: Setting this->totalEntries=%d ... - CALLED!', $counter));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-ABSTRACT-FILE: Setting this->totalEntries=%d ... - CALLED!', $counter));
$this->totalEntries = $counter;
}
* @return void
*/
protected final function incrementCounter () {
- // Get it
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-ABSTRACT-FILE: CALLED!');
+ // Count up
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-ABSTRACT-FILE: CALLED!');
$this->totalEntries++;
// Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-ABSTRACT-FILE: EXIT!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-ABSTRACT-FILE: EXIT!');
}
/**
* @return $fileObject An instance of a SplFileObject
*/
public final function getFileObject () {
+ // Call pointer instanze
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-ABSTRACT-FILE: CALLED!');
return $this->getPointerInstance()->getFileObject();
}
*/
public final function getFilename () {
// Invole file object's method
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-ABSTRACT-FILE: CALLED!');
return $this->getFileObject()->getFilename();
}
*/
public function closeFile () {
// Close down pointer instance as well by unsetting it
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-ABSTRACT-FILE: CALLED!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-ABSTRACT-FILE: CALLED!');
$this->unsetPointerInstance();
// Trace message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-ABSTRACT-FILE: EXIT!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-ABSTRACT-FILE: EXIT!');
}
/**
*/
public function size () {
// Call pointer instance
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-ABSTRACT-FILE: CALLED!');
return $this->getPointerInstance()->size();
}
*/
public function readFromFile () {
// Call pointer instance
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-ABSTRACT-FILE: CALLED!');
return $this->getPointerInstance()->readFromFile();
}
* an invalid file resource
*/
public function writeToFile (string $dataStream) {
+ // Check parameter
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-ABSTRACT-FILE: dataStream()=%d - CALLED!', strlen($dataStream)));
+ if (empty($dataStream)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "dataStream" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Call pointer instance
return $this->getPointerInstance()->writeToFile($dataStream);
}
*/
public final function isEndOfFileReached () {
// Call pointer instance
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-ABSTRACT-FILE: CALLED!');
return $this->getPointerInstance()->isEndOfFileReached();
}
// Import framework stuff
use Org\Mxchange\CoreFramework\Filesystem\CloseableFile;
use Org\Mxchange\CoreFramework\Filesystem\FilePointer;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Generic\NullPointerException;
use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
*/
protected function __construct (string $className) {
// Call parent constructor
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FILE-IO: className=%s - CONSTRUCTED!', $className));
parent::__construct($className);
+
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-FILE-IO: EXIT!');
}
/**
*/
public final function __destruct() {
// Is there a resource pointer? Then we have to close the file here!
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-IO: this->fileObject[]=%s - DESTRUCTOR!', gettype($this->getFileObject())));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FILE-IO: this->fileObject[]=%s - DESTRUCTOR!', gettype($this->getFileObject())));
if (is_object($this->getFileObject())) {
// Try to close a file
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-IO: Calling this->closeFile() ...');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-FILE-IO: Invoking this->closeFile() ...');
$this->closeFile();
}
parent::__destruct();
// Trace message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-IO: EXIT!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-FILE-IO: EXIT!');
}
/**
*/
public function closeFile () {
// Validate parameter
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-IO: fileName=%s - CALLED!', $this->getFileObject()->getPathname()));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FILE-IO: fileName=%s - CALLED!', $this->getFileObject()->getPathname()));
if (is_null($this->getFileObject())) {
// Pointer not initialized
- throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
+ throw new NullPointerException($this, FrameworkInterface::EXCEPTION_IS_NULL_POINTER);
} elseif (!is_object($this->getFileObject())) {
// Pointer is not a valid resource!
- throw new LogicException(sprintf('this->fileObject[]=%s is no object', gettype($this->getFileObject())));
+ throw new LogicException(sprintf('this->fileObject[]=%s is no object', gettype($this->getFileObject())), FrameworkInterface::EXCEPTION_LOGIC_EXCEPTION);
}
// Close the file pointer by NULL-ing it
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-IO: Closing file %s ...', $this->getFileObject()->getPathname()));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-FILE-IO: Closing file %s ...', $this->getFileObject()->getPathname()));
$this->resetFileObject();
// Trace message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-IO: EXIT!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-FILE-IO: EXIT!');
}
/**
*/
protected final function resetFileObject () {
// Set it to NULL
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-FILE-IO: Setting this->fileObject=NULL - CALLED!');
$this->fileObject = NULL;
+
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-FILE-IO: EXIT!');
}
/**
*/
public function seek (int $offset, int $whence = SEEK_SET) {
// Validate parameter
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-IO: offset=%d,whence=%d - CALLED!', $offset, $whence));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FILE-IO: offset=%d,whence=%d - CALLED!', $offset, $whence));
if ($offset < 0) {
// Throw exception
throw new OutOfBoundsException(sprintf('offset=%d is not valid', $offset));
$status = $this->getFileObject()->fseek($offset, $whence);
// Return status
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-IO: status=%d - EXIT!', $status));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FILE-IO: status=%d - EXIT!', $status));
return $status;
}
*/
public function size () {
// Get current seek position
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-IO: CALLED!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-FILE-IO: CALLED!');
$seekPosition = $this->determineSeekPosition();
// Seek to end
$seekStatus = $this->seek(0, SEEK_END);
// Get position again (which is the end of the file)
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-IO: seekStatus[%s]=%d', gettype($seekStatus), $seekStatus));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-FILE-IO: seekStatus[%s]=%d', gettype($seekStatus), $seekStatus));
$size = $this->determineSeekPosition();
// Reset seek position to old
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-IO: size[%s]=%d', gettype($size), $size));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-FILE-IO: size[%s]=%d', gettype($size), $size));
$this->seek($seekPosition);
// Return size
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-IO: size=%d - EXIT!', $size));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FILE-IO: size=%d - EXIT!', $size));
return $size;
}
// Import framework stuff
use Org\Mxchange\CoreFramework\Filesystem\FrameworkDirectory;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Generic\NullPointerException;
use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*/
public function __destruct() {
// Is there a resource pointer? Then we have to close the directory here!
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('FRAMEWORK-DIRECTORY-POINTER: DESTRUCTED!');
if ($this->getDirectoryIteratorInstance() instanceof DirectoryIterator) {
// Try to close a directory
$this->closeDirectory();
// Call the parent destructor
parent::__destruct();
+
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('FRAMEWORK-DIRECTORY-POINTER: EXIT!');
}
/**
*/
public static final function createFrameworkDirectoryPointer (string $pathName) {
// Some pre-sanity checks...
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('FRAMEWORK-DIRECTORY-POINTER: pathName=%s - CALLED!', $pathName));
if (empty($pathName)) {
// Throw IAE
- throw new InvalidArgumentException('Parameter "pathName" is empty');
+ throw new InvalidArgumentException('Parameter "pathName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif (!is_dir($pathName)) {
// Not a directory
throw new PathIsNoDirectoryException($pathName, self::EXCEPTION_INVALID_PATH_NAME);
$pointerInstance->setPathName($pathName);
// Return the instance
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DIRECTORY-POINTER: Opened pathName=' . $pathName . ' - EXIT!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('DIRECTORY-POINTER: pointerInstance=%s - EXIT!', $pointerInstance->__toString()));
return $pointerInstance;
}
*/
public function readRawDirectory () {
// Can the next entry be read?
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DIRECTORY-POINTER: CALLED!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('DIRECTORY-POINTER: CALLED!');
assert($this->getDirectoryIteratorInstance()->valid());
// Read data from the directory pointer and return it
$currentEntry = $this->getDirectoryIteratorInstance()->current();
// Return found entry
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DIRECTORY-POINTER: currentEntry[%s]=%s - EXIT!', gettype($currentEntry), $currentEntry));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('DIRECTORY-POINTER: currentEntry[%s]=%s - EXIT!', gettype($currentEntry), $currentEntry));
return $currentEntry;
}
*
* @param $except Some parts of a directory we want to ignore. Valid: directory and file names, other values will be silently ignored
* @return SplFileInfo An instance of a SplFileInfo class
+ * @throws InvalidArgumentException If a parameter has an invalid value
*/
public function readDirectoryExcept (array $except = []) {
// No exceptions given?
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DIRECTORY-POINTER: except()=%d - CALLED!', count($except)));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('DIRECTORY-POINTER: except()=%d - CALLED!', count($except)));
if (count($except) == 0) {
// No exception given, so read all files and directories, but not recursive
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DIRECTORY-POINTER: No exceptions given, please use readRawDirectory() instead!');
- return $this->readRawDirectory();
+ throw new InvalidArgumentException('Parameter "except" is an empty array', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif (!$this->getDirectoryIteratorInstance()->valid()) {
// No more left to read
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DIRECTORY-POINTER: EOD reached - EXIT!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('DIRECTORY-POINTER: EOD reached - EXIT!');
return NULL;
}
$currentEntry = $this->readRawDirectory();
// Shall we exclude directories?
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DIRECTORY-POINTER: currentEntry[]=%s', gettype($currentEntry)));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('DIRECTORY-POINTER: currentEntry[]=%s', gettype($currentEntry)));
if (is_object($currentEntry)) {
// Get file name
$fileInfoInstance = $currentEntry;
// Is it a dot-directory or excluded?
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DIRECTORY-POINTER: fileInfoInstance->filename=%s,isDot=%d', $fileInfoInstance->getFilename(), intval($this->getDirectoryIteratorInstance()->isDot())));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('DIRECTORY-POINTER: fileInfoInstance->filename=%s,isDot=%d', $fileInfoInstance->getFilename(), intval($this->getDirectoryIteratorInstance()->isDot())));
while ($this->getDirectoryIteratorInstance()->valid() && ($this->getDirectoryIteratorInstance()->isDot() || in_array($fileInfoInstance->getFilename(), $except))) {
// Update current instance
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DIRECTORY-POINTER: fileInfoInstance->filename=%s,isDot=%d', $fileInfoInstance->getFilename(), intval($this->getDirectoryIteratorInstance()->isDot())));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('DIRECTORY-POINTER: fileInfoInstance->filename=%s,isDot=%d', $fileInfoInstance->getFilename(), intval($this->getDirectoryIteratorInstance()->isDot())));
$fileInfoInstance = $this->readRawDirectory();
// To next entry
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DIRECTORY-POINTER: Invoking directoryIteratorInstance->next() ...');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('DIRECTORY-POINTER: Invoking directoryIteratorInstance->next() ...');
$this->getDirectoryIteratorInstance()->next();
}
}
// Return read line
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DIRECTORY-POINTER: fileInfoInstance[%s]=%s - EXIT!', gettype($fileInfoInstance), $fileInfoInstance));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('DIRECTORY-POINTER: fileInfoInstance[%s]=%s - EXIT!', gettype($fileInfoInstance), $fileInfoInstance));
return $fileInfoInstance;
}
*/
public function closeDirectory () {
// Close the directory by unsetting it
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DIRECTORY-POINTER: CALLED!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('DIRECTORY-POINTER: CALLED!');
$this->unsetDirectoryIteratorInstance();
$this->setPathName('');
+
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('DIRECTORY-POINTER: CALLED!');
}
/**
use Org\Mxchange\CoreFramework\Filesystem\FileNotFoundException;
use Org\Mxchange\CoreFramework\Filesystem\FileReadProtectedException;
use Org\Mxchange\CoreFramework\Filesystem\Pointer\InputPointer;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Generic\NullPointerException;
use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
// Import SPL stuff
+use \InvalidArgumentException;
use \SplFileInfo;
use \SplFileObject;
+use \UnexpectedValueException;
/**
* A class for reading files
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*/
public static final function createFrameworkRawFileInputPointer (SplFileInfo $fileInstance) {
// Some pre-sanity checks...
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('RAW-FILE-INPUT-POINTER: fileInstance[%s]=%s - CALLED!', get_class($fileInstance), $fileInstance->__toString()));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('RAW-FILE-INPUT-POINTER: fileInstance[%s]=%s - CALLED!', get_class($fileInstance), $fileInstance->__toString()));
if (!FrameworkBootstrap::isReachableFilePath($fileInstance)) {
// File cannot be accessed (due to open_basedir restriction)
throw new FileIoException($fileInstance, self::EXCEPTION_FILE_NOT_REACHABLE);
$fileObject = $fileInstance->openFile('rb');
// Is it valid?
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('RAW-FILE-INPUT-POINTER: fileObject[]=%s', gettype($fileObject)));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('RAW-FILE-INPUT-POINTER: fileObject[]=%s', gettype($fileObject)));
if (!($fileObject instanceof SplFileObject)) {
// Something bad happend
throw new FileIoException($fileInstance, self::EXCEPTION_FILE_POINTER_INVALID);
}
// Create new instance
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('RAW-FILE-INPUT-POINTER: fileObject.pathname=%s', $fileObject->getPathname()));
$pointerInstance = new FrameworkRawFileInputPointer();
// Set file pointer and file name
$pointerInstance->setFileObject($fileObject);
// Return the instance
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('RAW-FILE-INPUT-POINTER: pointerInstance=%s - EXIT!', $pointerInstance->__toString()));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('RAW-FILE-INPUT-POINTER: pointerInstance=%s - EXIT!', $pointerInstance->__toString()));
return $pointerInstance;
}
* @throws LogicException If there is no object being set
*/
public function readFromFile () {
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('RAW-FILE-INPUT-POINTER: CALLED!');
if (is_null($this->getFileObject())) {
// Pointer not initialized
- throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
+ throw new NullPointerException($this, FrameworkInterface::EXCEPTION_IS_NULL_POINTER);
} elseif (!is_object($this->getFileObject())) {
// Pointer is not a valid resource!
- throw new LogicException(sprintf('this->fileObject[]=%s is no object', gettype($this->getFileObject())));
+ throw new LogicException(sprintf('this->fileObject[]=%s is no object', gettype($this->getFileObject())), FrameworkInterface::EXCEPTION_LOGIC_EXCEPTION);
}
// Read data from the file pointer and return it
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('RAW-FILE-INPUT-POINTER: Invoking this->read(1024) - EXIT!');
return $this->read(1024);
}
*/
public function readLine () {
// Not supported in binary files ...
- throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
*
* @param $bytes Amount of bytes to read
* @return $data Data read from file
+ * @throws InvalidArgumentException If a parameter is not valid
+ * @throws UnexpectedValueException If fread() returns a non-string value
*/
public function read (int $bytes = 0) {
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('RAW-FILE-INPUT-POINTER: bytes=%d - CALLED!', $bytes));
+ if ($bytes < 0) {
+ // Throw IAE
+ throw new InvalidArgumentException(sprintf('bytes=%d is an invalid value, only zero or postive numbers are accepted', $bytes));
+ }
+
// Try to read given characters
$data = $this->getFileObject()->fread($bytes);
+ // Is it valid?
+ if (!is_string($data)) {
+ // Is not a string
+ throw new UnexpectedValueException(sprintf('Returned data[]=%s is not expected.', gettype($data)), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
+ }
+
// Then return it
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('RAW-FILE-INPUT-POINTER: data()=%d - EXIT!', strlen($data)));
return $data;
}
* @throws UnsupportedOperationException If this method is called
*/
public function analyzeFileStructure () {
- throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
* @throws UnsupportedOperationException If this method is called
*/
public function next () {
- throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
* @throws UnsupportedOperationException If this method is called
*/
public function valid () {
- throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
* @throws UnsupportedOperationException If this method is called
*/
public function key () {
- throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
}
use Org\Mxchange\CoreFramework\Filesystem\FileNotFoundException;
use Org\Mxchange\CoreFramework\Filesystem\FileReadProtectedException;
use Org\Mxchange\CoreFramework\Filesystem\Pointer\InputPointer;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Generic\NullPointerException;
use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*/
public static final function createFrameworkTextFileInputPointer (SplFileInfo $fileInstance) {
// Check parameter
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('RAW-FILE-INPUT-POINTER: fileInstance[%s]=%s - CALLED!', get_class($fileInstance), $fileInstance->__toString()));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('RAW-FILE-INPUT-POINTER: fileInstance[%s]=%s - CALLED!', get_class($fileInstance), $fileInstance->__toString()));
if (!FrameworkBootstrap::isReachableFilePath($fileInstance)) {
// File cannot be reached
throw new FileIoException($fileInstance, self::EXCEPTION_FILE_NOT_REACHABLE);
$fileObject = $fileInstance->openFile('r');
// Is it valid?
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('TEXT-FILE-INPUT-POINTER: fileObject[]=%s', gettype($fileObject)));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('TEXT-FILE-INPUT-POINTER: fileObject[]=%s', gettype($fileObject)));
if (!($fileObject instanceof SplFileObject)) {
// Something bad happend
throw new FileIoException($fileInstance, self::EXCEPTION_FILE_POINTER_INVALID);
$pointerInstance->setFileObject($fileObject);
// Return the instance
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('TEXT-FILE-INPUT-POINTER: pointerInstance=%s - EXIT!', $pointerInstance->__toString()));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('TEXT-FILE-INPUT-POINTER: pointerInstance=%s - EXIT!', $pointerInstance->__toString()));
return $pointerInstance;
}
*/
public function readFromFile () {
// Read 1024 Byte data from the file pointer and return it
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('RAW-FILE-INPUT-POINTER: CALLED!');
return $this->read(1024);
}
*/
public function readLine () {
// Read whole line from the file pointer and return it
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('RAW-FILE-INPUT-POINTER: CALLED!');
return $this->read();
}
*/
public function read (int $bytes = 0) {
// Some sanity checks
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('RAW-FILE-INPUT-POINTER: bytes=%d - CALLED!', $bytes));
if ($bytes < 0) {
// Cannot be below zero
throw new OutOfBoundsException(sprintf('bytes=%d is not valid', $bytes));
} elseif (is_null($this->getFileObject())) {
// Pointer not initialized
- throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
+ throw new NullPointerException($this, FrameworkInterface::EXCEPTION_IS_NULL_POINTER);
} elseif (!is_object($this->getFileObject())) {
// Pointer is not a valid resource!
- throw new LogicException(sprintf('this->fileObject[]=%s is no object', gettype($this->getFileObject())));
+ throw new LogicException(sprintf('this->fileObject[]=%s is no object', gettype($this->getFileObject())), FrameworkInterface::EXCEPTION_LOGIC_EXCEPTION);
}
// Is $bytes set?
if ($bytes > 0) {
// Try to read given characters
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('RAW-FILE-INPUT-POINTER: Invoking this->fileObject->fread(%d) ...', $bytes));
$data = $this->getFileObject()->fread($bytes);
} else {
// Try to read whole line
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('RAW-FILE-INPUT-POINTER: Invoking this->fileObject->fgets() ...');
$data = $this->getFileObject()->fgets();
}
// Then return it
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('RAW-FILE-INPUT-POINTER: data()=%d - EXIT!', strlen($data)));
return $data;
}
* @throws UnsupportedOperationException If this method is called
*/
public function analyzeFileStructure () {
- throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
* @throws UnsupportedOperationException If this method is called
*/
public function next () {
- throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
* @throws UnsupportedOperationException If this method is called
*/
public function valid () {
- throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
* @throws UnsupportedOperationException If this method is called
*/
public function key () {
- throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
}
use Org\Mxchange\CoreFramework\Filesystem\FileReadProtectedException;
use Org\Mxchange\CoreFramework\Filesystem\FileWriteProtectedException;
use Org\Mxchange\CoreFramework\Filesystem\PathWriteProtectedException;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Generic\NullPointerException;
use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*/
public static final function createFrameworkFileInputOutputPointer (SplFileInfo $fileInstance) {
// Some pre-sanity checks...
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-INPUT-OUTPUT-POINTER: fileInstance[%s]=%s - CALLED!', get_class($fileInstance), $fileInstance));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('FILE-INPUT-OUTPUT-POINTER: fileInstance[%s]=%s - CALLED!', get_class($fileInstance), $fileInstance));
if (!FrameworkBootstrap::isReachableFilePath($fileInstance)) {
// File exists but cannot be read
throw new FileIoException($fileInstance, self::EXCEPTION_FILE_NOT_REACHABLE);
$fileObject = $fileInstance->openFile('c+b');
// Is it valid?
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-INPUT-OUTPUT-POINTER: fileObject[]=%s', gettype($fileObject)));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('FILE-INPUT-OUTPUT-POINTER: fileObject[]=%s', gettype($fileObject)));
if (!($fileObject instanceof SplFileObject)) {
// Something bad happend
throw new FileIoException($fileInstance->getPathname(), self::EXCEPTION_FILE_POINTER_INVALID);
$pointerInstance->setFileObject($fileObject);
// Return the instance
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-INPUT-OUTPUT-POINTER: pointerInstance=%s - EXIT!', $pointerInstance->__toString()));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('FILE-INPUT-OUTPUT-POINTER: pointerInstance=%s - EXIT!', $pointerInstance->__toString()));
return $pointerInstance;
}
*/
public function readFromFile () {
// Read data from the file pointer and return it
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-INPUT-OUTPUT-POINTER: CALLED!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('FILE-INPUT-OUTPUT-POINTER: CALLED!');
$data = $this->read(1024);
// Return data
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-INPUT-OUTPUT-POINTER: data[%s]=%d - EXIT!', gettype($data), $data));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('FILE-INPUT-OUTPUT-POINTER: data[%s]=%d - EXIT!', gettype($data), $data));
return $data;
}
*/
public function writeToFile (string $dataStream) {
// Validate parameter
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-INPUT-OUTPUT-POINTER: dataStream(%d)=%s - CALLED!', strlen($dataStream), $dataStream));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('FILE-INPUT-OUTPUT-POINTER: dataStream(%d)=%s - CALLED!', strlen($dataStream), $dataStream));
if (empty($dataStream)) {
// Empty dataStream
- throw new InvalidArgumentException('Parameter "dataStream" is empty');
+ throw new InvalidArgumentException('Parameter "dataStream" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
}
// Get length
$length = strlen($dataStream);
// Write data to the file pointer and return written bytes
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-INPUT-OUTPUT-POINTER: Calling this->fileObject->fwrite(%s,%d) ...', $dataStream, $length));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('FILE-INPUT-OUTPUT-POINTER: Invoking this->fileObject->fwrite(%s,%d) ...', $dataStream, $length));
$status = $this->getFileObject()->fwrite($dataStream, $length);
// Return status
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-INPUT-OUTPUT-POINTER: status[%s]=%d - EXIT!', gettype($status), $status));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('FILE-INPUT-OUTPUT-POINTER: status[%s]=%d - EXIT!', gettype($status), $status));
return $status;
}
*/
public function writeAtPosition (int $seekPosition, string $dataStream) {
// Validate parameter
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-INPUT-OUTPUT-POINTER: seekPosition=%d,dataStream(%d)=%s - CALLED!', $seekPosition, strlen($dataStream), $dataStream));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('FILE-INPUT-OUTPUT-POINTER: seekPosition=%d,dataStream(%d)=%s - CALLED!', $seekPosition, strlen($dataStream), $dataStream));
if ($seekPosition < 0) {
// Invalid seek position
throw new OutOfBoundsException(sprintf('seekPosition=%d is not valid.', $seekPosition));
} elseif (empty($dataStream)) {
// Empty dataStream
- throw new InvalidArgumentException('Parameter "dataStream" is empty');
+ throw new InvalidArgumentException('Parameter "dataStream" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif (($this->getFileSize() > 0 || $seekPosition > 0) && $this->seek($seekPosition) === -1) {
// Could not seek
throw new InvalidArgumentException(sprintf('Could not seek to seekPosition=%d', $seekPosition));
}
// Then write the data at that position
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-INPUT-OUTPUT-POINTER: Calling this->writeToFile(%s) ...', $dataStream));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('FILE-INPUT-OUTPUT-POINTER: Invoking this->writeToFile(%s) ...', $dataStream));
$status = $this->writeToFile($dataStream);
// Return status
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-INPUT-OUTPUT-POINTER: status[%s]=%d - EXIT!', gettype($status), $status));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('FILE-INPUT-OUTPUT-POINTER: status[%s]=%d - EXIT!', gettype($status), $status));
return $status;
}
*/
public function rewind () {
/// Rewind the pointer
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-INPUT-OUTPUT-POINTER: CALLED!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('FILE-INPUT-OUTPUT-POINTER: CALLED!');
$this->getFileObject()->rewind();
// Trace message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-INPUT-OUTPUT-POINTER: EXIT!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('FILE-INPUT-OUTPUT-POINTER: EXIT!');
}
/**
*/
public function seek (int $seekPosition, int $whence = SEEK_SET) {
// Validate parameter
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-INPUT-OUTPUT-POINTER: seekPosition=%d,whence=%d - CALLED!', $seekPosition, $whence));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('FILE-INPUT-OUTPUT-POINTER: seekPosition=%d,whence=%d - CALLED!', $seekPosition, $whence));
if ($seekPosition < 0) {
// Invalid seek position
throw new OutOfBoundsException(sprintf('seekPosition=%d is not valid.', $seekPosition));
+ } elseif ($whence < 0) {
+ // Invalid seek position
+ throw new OutOfBoundsException(sprintf('whence=%d is not valid.', $whence));
}
// Move the file pointer
$status = $this->getFileObject()->fseek($seekPosition, $whence);
// Return status
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-INPUT-OUTPUT-POINTER: status[%s]=%d - EXIT!', gettype($status), $status));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('FILE-INPUT-OUTPUT-POINTER: status[%s]=%d - EXIT!', gettype($status), $status));
return $status;
}
*/
public function readLine () {
// Read whole line
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-INPUT-OUTPUT-POINTER: CALLED!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('FILE-INPUT-OUTPUT-POINTER: CALLED!');
$data = $this->read();
// Return data
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-INPUT-OUTPUT-POINTER: data[%s]=%s - EXIT!', gettype($data), $data));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('FILE-INPUT-OUTPUT-POINTER: data[%s]=%s - EXIT!', gettype($data), $data));
return $data;
}
*/
public function read (int $bytes = 0) {
// Validatre parameter
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-INPUT-OUTPUT-POINTER: bytes=%d - CALLED!', $bytes));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('FILE-INPUT-OUTPUT-POINTER: bytes=%d - CALLED!', $bytes));
if ($bytes < 0) {
// Bytes cannot be lesser than zero
throw new OutOfBoundsException(sprintf('bytes=%d is not valid', $bytes));
}
// Then return it
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-INPUT-OUTPUT-POINTER: data[%s]=%s - EXIT!', gettype($data), $data));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('FILE-INPUT-OUTPUT-POINTER: data[%s]=%s - EXIT!', gettype($data), $data));
return $data;
}
* @throws UnsupportedOperationException If this method is called
*/
public function analyzeFileStructure () {
- throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
* @throws UnsupportedOperationException If this method is called
*/
public function next () {
- throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
* @throws UnsupportedOperationException If this method is called
*/
public function valid () {
- throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
* @throws UnsupportedOperationException If this method is called
*/
public function key () {
- throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
*/
public function getFileSize () {
// Get file's data
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-INPUT-OUTPUT-POINTER: CALLED!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('FILE-INPUT-OUTPUT-POINTER: CALLED!');
$fileData = $this->getFileObject()->fstat();
// Make sure the required array key is there
if (!isset($fileData['size'])) {
// Not valid array
- throw new UnexpectedValueException(sprintf('fileData=%s has no element "size"', print_r($fileData, TRUE)));
+ throw new UnexpectedValueException(sprintf('fileData=%s has no element "size"', print_r($fileData, TRUE)), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
}
// Return size
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-INPUT-OUTPUT-POINTER: fileData[size]=%d - EXIT!', $fileData['size']));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('FILE-INPUT-OUTPUT-POINTER: fileData[size]=%d - EXIT!', $fileData['size']));
return $fileData['size'];
}
use Org\Mxchange\CoreFramework\EntryPoint\ApplicationEntryPoint;
use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
use Org\Mxchange\CoreFramework\Filesystem\FileNotFoundException;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
+use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
use Org\Mxchange\CoreFramework\Stream\Filesystem\FileInputStreamer;
use Org\Mxchange\CoreFramework\Stream\Filesystem\FileOutputStreamer;
// Import SPL stuff
+use \InvalidArgumentException;
+use \OutOfBoundsException;
use \SplFileInfo;
/**
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*/
public static final function createFileIoStream () {
// Create new instance
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('FILE-IO-STREAM: CALLED!');
$ioInstance = new FileIoStream();
// Return the instance
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('FILE-IO-STREAM: ioInstance=%s - EXIT!', $ioInstance->__toString()));
return $ioInstance;
}
* @param $dataArray The data we shall store to the file
* @return void
* @see FileOutputStreamer
- * @todo This method needs heavy rewrite
+ * @throws InvalidArgumentException If an invalid parameter was given
+ * @throws OutOfBoundsException If an expected array element wasn't found
*/
public final function saveFile (SplFileInfo $fileInfoInstance, array $dataArray) {
- // Try it five times
- $dirName = '';
- $fileInstance = NULL;
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('FILE-IO-STREAM: fileInfoInstance=%s,dataArray()=%d - CALLED!', $fileInfoInstance, count($dataArray)));
+ if (count($dataArray) < 2) {
+ // Not valid array, at least 2 elements must be there!
+ throw new InvalidArgumentException(sprintf('Parameter "dataArray" should have at least 2 elements, has %d', count($dataArray)));
+ } else if (!isset($dataArray[0])) {
+ // Array element 0 not found
+ throw new OutOfBoundsException(sprintf('Array element dataArray[0] not found, dataArray=%s', json_encode($dataArray)));
+ } else if (!isset($dataArray[1])) {
+ // Array element 1 not found
+ throw new OutOfBoundsException(sprintf('Array element dataArray[1] not found, dataArray=%s', json_encode($dataArray)));
+ }
- for ($idx = 0; $idx < 5; $idx++) {
+ try {
// Get a file output pointer
- try {
- $fileInstance = ObjectFactory::createObjectByConfiguredName('file_raw_output_class', array($fileInfoInstance, 'wb'));
- } catch (FileNotFoundException $e) {
- // Bail out
- ApplicationEntryPoint::exitApplication('The application has made a fatal error. Exception: ' . $e->__toString() . ' with message: ' . $e->getMessage());
- }
+ $fileInstance = ObjectFactory::createObjectByConfiguredName('file_raw_output_class', [$fileInfoInstance, 'wb']);
+ } catch (FileNotFoundException $e) {
+ // Bail out
+ ApplicationEntryPoint::exitApplication('The application has made a fatal error. Exception: ' . $e->__toString() . ' with message: ' . $e->getMessage());
}
// Write a header information for validation purposes
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('FILE-IO-STREAM: Writing header to fileInstance=%s ...', $fileInstance->__toString()));
$fileInstance->writeToFile(sprintf('%s%s%s%s%s%s%s%s%s' . PHP_EOL,
self::FILE_IO_FILE_HEADER_ID,
self::FILE_IO_SEPARATOR,
));
// Encode the (maybe) binary stream with Base64
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('FILE-IO-STREAM: Encoding %d bytes to BASE64 string ...', strlen($dataArray[1])));
$b64Stream = base64_encode($dataArray[1]);
- // write the data line by line
+ // write the data line-by-line
$line = str_repeat(' ', 50); $idx = 0;
while (strlen($line) == 50) {
// Get 50 chars or less
$line = substr($b64Stream, $idx, 50);
// Save it to the stream
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('FILE-IO-STREAM: Writing %d bytes to file ...', strlen($line)));
$fileInstance->writeToFile(sprintf('%s%s%s%s%s' . PHP_EOL,
self::FILE_IO_DATA_BLOCK_ID,
self::FILE_IO_SEPARATOR,
}
// Close the file
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('FILE-IO-STREAM: Closing file ...');
unset($fileInstance);
+
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('FILE-IO-STREAM: EXIT!');
}
/**
*/
public final function loadFileContents (SplFileInfo $infoInstance) {
// Initialize some variables and arrays
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('FILE-IO-STREAM: infoInstance=%s - CALLED!', $infoInstance));
$inputBuffer = '';
$lastBuffer = '';
$header = [];
$fileInstance = ObjectFactory::createObjectByConfiguredName('file_raw_input_class', array($infoInstance));
// Read all it's contents (we very and transparently decompress it below)
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('FILE-IO-STREAM: fileInstance=%s', $fileInstance->__toString()));
while ($readRawLine = $fileInstance->readFromFile()) {
// Add the read line to the buffer
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('FILE-IO-STREAM: Adding %d read bytes to input buffer.', strlen($readRawLine)));
$inputBuffer .= $readRawLine;
// Break infinite loop maybe caused by the input handler
if ($lastBuffer == $inputBuffer) {
+ // Break out of loop, EOF reached?
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('FILE-IO-STREAM: EOF reached!');
break;
}
}
// Close directory handle
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('FILE-IO-STREAM: Closing file ...');
unset($fileInstance);
// Convert it into an array
- $inputBuffer = explode(chr(10), $inputBuffer);
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('FILE-IO-STREAM: Read inputBuffer=%d bytes from infoInstance=%s', strlen($inputBuffer), $infoInstance));
+ $inputArray = explode(chr(10), $inputBuffer);
// Now process the read lines and verify it's content
- foreach ($inputBuffer as $rawLine) {
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('FILE-IO-STREAM: inputArray()=%d', count($inputArray)));
+ foreach ($inputArray as $rawLine) {
// Trim it a little but not the leading spaces/tab-stops
$rawLine = rtrim($rawLine);
// Analyze this line
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('FILE-IO-STREAM: rawLine()=%d', strlen($rawLine)));
if (substr($rawLine, 0, 5) == self::FILE_IO_FILE_HEADER_ID) {
// Header found, so let's extract it
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('FILE-IO-STREAM: Found header, rawLine=%s', $rawLine));
$header = explode(self::FILE_IO_SEPARATOR, $rawLine);
- $header = trim($header[1]);
+ $headerLine = trim($header[1]);
// Now we must convert it again into an array
- $header = explode(self::FILE_IO_CHUNKER, $header);
+ $header = explode(self::FILE_IO_CHUNKER, $headerLine);
// Is the header (maybe) valid?
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('FILE-IO-STREAM: header()=%d', count($header)));
if (count($header) != 4) {
// Throw an exception
- throw new InvalidArrayCountException(array($this, 'header', count($header), 4), self::EXCEPTION_ARRAY_HAS_INVALID_COUNT);
+ throw new InvalidArrayCountException([$this, 'header', count($header), 4], self::EXCEPTION_ARRAY_HAS_INVALID_COUNT);
}
} elseif (substr($rawLine, 0, 5) == self::FILE_IO_DATA_BLOCK_ID) {
// Is a data line!
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('FILE-IO-STREAM: Data line found rawLine=%s', $rawLine));
$data = explode(self::FILE_IO_SEPARATOR, $rawLine);
- $data = $data[1];
+ $dataLine = $data[1];
// First element is the data, second the MD5 checksum
- $data = explode(self::FILE_IO_CHUNKER, $data);
+ $data = explode(self::FILE_IO_CHUNKER, $dataLine);
// Validate the read line
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('FILE-IO-STREAM: data()=%d', count($data)));
if (count($data) == 2) {
- if (md5($data[0]) != $data[1]) {
+ // Generate checksum (MD5 is okay here)
+ $checksum = md5($data[0]);
+
+ // Check if it matches provided one
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('FILE-IO-STREAM: checksum=%s,data[1]=%s', $checksum, $data[1]));
+ if ($checksum != $data[1]) {
// MD5 hash did not match!
- throw new InvalidMD5ChecksumException(array($this, md5($data[0]), $data[1]), self::EXCEPTION_MD5_CHECKSUMS_MISMATCH);
+ throw new InvalidMD5ChecksumException([$this, $checksum, $data[1]], self::EXCEPTION_MD5_CHECKSUMS_MISMATCH);
}
} else {
// Invalid count!
- throw new InvalidArrayCountException(array($this, 'data', count($data), 2), self::EXCEPTION_ARRAY_HAS_INVALID_COUNT);
+ throw new InvalidArrayCountException([$this, 'data', count($data), 2], self::EXCEPTION_ARRAY_HAS_INVALID_COUNT);
}
// Add this to the readData string
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('FILE-IO-STREAM: Adding %d raw data to input stream', strlen($data[0])));
$readData .= $data[0];
} else {
// Other raw lines than header/data tagged lines and re-add the new-line char
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('FILE-IO-STREAM: Adding rawLine=%s(%d) + PHP_EOL to input stream', $rawLine, strlen($rawLine)));
$readData .= $rawLine . PHP_EOL;
}
}
// Was raw lines read and no header/data?
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('FILE-IO-STREAM: readData()=%d,header()=%d,data()=%d', strlen($readData), count($header), count($data)));
if ((!empty($readData)) && (count($header) == 0) && (count($data) == 0)) {
// Return raw lines back
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('FILE-IO-STREAM: readData()=%d - EXIT!', strlen($readData)));
return $readData;
}
// Was a header found?
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('FILE-IO-STREAM: header()=%d', count($header)));
if (count($header) != 4) {
// Throw an exception
- throw new InvalidArrayCountException(array($this, 'header', count($header), 4), self::EXCEPTION_ARRAY_HAS_INVALID_COUNT);
+ throw new InvalidArrayCountException([$this, 'header', count($header), 4], self::EXCEPTION_ARRAY_HAS_INVALID_COUNT);
}
// Decode all from Base64
- $readData = @base64_decode($readData);
+ $decodedData = @base64_decode($readData);
// Does the size match?
- if (strlen($readData) != $header[2]) {
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('FILE-IO-STREAM: decodedData()=%d,header[2]=%d', strlen($decodedData), $header[2]));
+ if (strlen($decodedData) != $header[2]) {
// Size did not match
- throw new InvalidDataLengthException(array($this, strlen($readData), $header[2]), self::EXCEPTION_UNEXPECTED_STRING_SIZE);
+ throw new InvalidDataLengthException([$this, strlen($decodedData), $header[2]], self::EXCEPTION_UNEXPECTED_STRING_SIZE);
}
+ // Generate checksum from whole read data
+ $checksum = md5($decodedData);
+
// Validate the decoded data with the final MD5 hash
- if (md5($readData) != $header[3]) {
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('FILE-IO-STREAM: checksum=%s,header[3]=%s', $checksum, $header[3]));
+ if ($checksum != $header[3]) {
// MD5 hash did not match!
- throw new InvalidMD5ChecksumException(array($this, md5($readData), $header[3]), self::EXCEPTION_MD5_CHECKSUMS_MISMATCH);
+ throw new InvalidMD5ChecksumException([$this, $checksum, $header[3]], self::EXCEPTION_MD5_CHECKSUMS_MISMATCH);
}
// Return all in an array
- return array(
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('FILE-IO-STREAM: header()=%d,decodedData()=%d - EXIT!', count($header), strlen($decodedData)));
+ return [
'header' => $header,
- 'data' => $readData
- );
+ 'data' => $decodedData,
+ ];
}
/**
* @throws UnsupportedOperationException If this method is called
*/
public function streamData (string $data) {
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.');
- throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+ // Not supported
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('FILE-IO-STREAM: data=()=%d - CALLED!', strlen($data)));
+ throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
* @todo 0% done
*/
public function determineSeekPosition () {
- $this->partialStub();
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('FILE-IO-STREAM: CALLED!');
+ DebugMiddleware::getSelfInstance()->partialStub();
}
/**
* @return $status Status of file seek: 0 = success, -1 = failed
*/
public function seek (int $offset, int $whence = SEEK_SET) {
- $this->partialStub('offset=' . $offset . ',whence=' . $whence);
+ // Check parameters
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('FILE-IO-STREAM: offset=%d,whence=%d - CALLED!', $offset, $whence));
+ if ($offset < 0) {
+ // Throw IAE
+ throw new InvalidArgumentException(sprintf('offset=%d is below zero', $offset), FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif ($whence < 0) {
+ // Throw IAE
+ throw new InvalidArgumentException(sprintf('whence=%d is below zero', $whence), FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
+ DebugMiddleware::getSelfInstance()->partialStub('offset=' . $offset . ',whence=' . $whence);
}
/**
* @return $size Size (in bytes) of file
*/
public function size () {
- $this->partialStub();
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('FILE-IO-STREAM: CALLED!');
+ DebugMiddleware::getSelfInstance()->partialStub();
}
}
use Org\Mxchange\CoreFramework\Filesystem\BaseFileIo;
use Org\Mxchange\CoreFramework\Filesystem\FileIoException;
use Org\Mxchange\CoreFramework\Filesystem\Pointer\OutputPointer;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Generic\NullPointerException;
// Import SPL stuff
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*/
public static final function createFrameworkRawFileOutputPointer (SplFileInfo $fileInstance, string $mode) {
// Is the parameter valid?
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('RAW-FILE-OUTPUT-POINTER: fileInstance=%s,mode=%s - CALLED!', $fileInstance->__toString(), $mode));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('RAW-FILE-OUTPUT-POINTER: fileInstance=%s,mode=%s - CALLED!', $fileInstance->__toString(), $mode));
if (empty($mode)) {
// No fileInstance given
- throw new InvalidArgumentException('Parameter "mode" is empty');
+ throw new InvalidArgumentException('Parameter "mode" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
}
// Try to open a handler
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('RAW-FILE-OUTPUT-POINTER: Invoking fileInstance->openFile(%s) ...', $mode));
$fileObject = $fileInstance->openFile($mode);
// Is it valid?
$pointerInstance->setFileObject($fileObject);
// Return the instance
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('RAW-FILE-OUTPUT-POINTER: pointerInstance=%s - EXIT!', $pointerInstance->__toString()));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('RAW-FILE-OUTPUT-POINTER: pointerInstance=%s - EXIT!', $pointerInstance->__toString()));
return $pointerInstance;
}
*/
public function writeToFile (string $dataStream) {
// Validate parameter and class own attributes
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('RAW-FILE-OUTPUT-POINTER: dataStream(%d)=%s (trimmed) - CALLED!', strlen($dataStream), trim($dataStream)));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('RAW-FILE-OUTPUT-POINTER: dataStream(%d)=%s (trimmed) - CALLED!', strlen($dataStream), trim($dataStream)));
if (empty($dataStream)) {
// Empty data stream
- throw new InvalidArgumentException('Parameter "dataStream" is empty');
+ throw new InvalidArgumentException('Parameter "dataStream" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif (is_null($this->getFileObject())) {
// Pointer not initialized
- throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
+ throw new NullPointerException($this, FrameworkInterface::EXCEPTION_IS_NULL_POINTER);
} elseif (!is_object($this->getFileObject())) {
// Pointer is not a valid resource!
- throw new LogicException(sprintf('this->fileObject[]=%s is no object', gettype($this->getFileObject())));
+ throw new LogicException(sprintf('this->fileObject[]=%s is no object', gettype($this->getFileObject())), FrameworkInterface::EXCEPTION_LOGIC_EXCEPTION);
}
// Write data to the file pointer and return written bytes
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('RAW-FILE-OUTPUT-POINTER: Invoking this->fileObject->fwrite(dataStream()=%d - EXIT!', strlen($dataStream)));
return $this->getFileObject()->fwrite($dataStream);
}
* @throws UnsupportedOperationException If this method is called
*/
public function analyzeFileStructure () {
- throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
* @throws UnsupportedOperationException If this method is called
*/
public function writeAtPosition (int $seedPosition, string $data) {
- throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
* @throws UnsupportedOperationException If this method is called
*/
public function next () {
- throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
* @throws UnsupportedOperationException If this method is called
*/
public function valid () {
- throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
* @throws UnsupportedOperationException If this method is called
*/
public function key () {
- throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
}
use Org\Mxchange\CoreFramework\Filesystem\BaseFileIo;
use Org\Mxchange\CoreFramework\Filesystem\FileIoException;
use Org\Mxchange\CoreFramework\Filesystem\Pointer\OutputPointer;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Generic\NullPointerException;
use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('TEXT-FILE-OUTPUT-POINTER: fileInstance[%s]=%s,mode=%s - CALLED!', get_class($fileInstance), $fileInstance->__toString(), $mode));
if (empty($mode)) {
// No filename given
- throw new InvalidArgumentException('Parameter "mode" is empty');
+ throw new InvalidArgumentException('Parameter "mode" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
}
// Try to open a handler
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('TEXT-FILE-OUTPUT-POINTER: dataStream=%s - CALLED!', $dataStream));
if (empty($dataStream)) {
// Invalid parameter
- throw new InvalidArgumentException('Parameter "dataStream" is empty');
+ throw new InvalidArgumentException('Parameter "dataStream" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif (is_null($this->getFileObject())) {
// Pointer not initialized
- throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
+ throw new NullPointerException($this, FrameworkInterface::EXCEPTION_IS_NULL_POINTER);
} elseif (!is_object($this->getFileObject())) {
// Pointer is not a valid object!
- throw new LogicException(sprintf('this->fileObject[]=%s is no object', gettype($this->getFileObject())));
+ throw new LogicException(sprintf('this->fileObject[]=%s is no object', gettype($this->getFileObject())), FrameworkInterface::EXCEPTION_LOGIC_EXCEPTION);
}
// Write data to the file pointer and return written bytes
* @throws UnsupportedOperationException If this method is called
*/
public function analyzeFileStructure () {
- throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
* @throws UnsupportedOperationException If this method is called
*/
public function writeAtPosition (int $seedPosition, string $data) {
- throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
* @throws UnsupportedOperationException If this method is called
*/
public function next () {
- throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
* @throws UnsupportedOperationException If this method is called
*/
public function valid () {
- throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
* @throws UnsupportedOperationException If this method is called
*/
public function key () {
- throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
}
// Import framework stuff
use Org\Mxchange\CoreFramework\Filesystem\File\BaseAbstractFile;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
// Import SPL stuff
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
*/
public function determineSeekPosition () {
// Not possible in text files
- throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
public function seek (int $offset, int $whence = SEEK_SET) {
// Not possible in text files
self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-TEXT-FILE: offset=' . $offset . ',whence=' . $whence);
- throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
* There is no need to read/write the whole file.
*/
self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-TEXT-FILE: infoInstance=' . $infoInstance);
- throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
}
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
// Import framework stuff
use Org\Mxchange\CoreFramework\Filesystem\Text\BaseInputTextFile;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Stream\Filesystem\CsvInputStreamer;
// Import SPL stuff
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d:] columnSeparator=%s,expectedMatches=%d - CALLED!', __METHOD__, __LINE__, $columnSeparator, $expectedMatches));
if (strlen($columnSeparator) === 0) {
// No empty column separator
- throw new InvalidArgumentException('Parameter "columnSeparator" is empty');
+ throw new InvalidArgumentException('Parameter "columnSeparator" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif ($expectedMatches < 0) {
// Below zero is not valid
throw new InvalidArgumentException(sprintf('expectedMatches=%d is below zero', $expectedMatches));
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d:] expectedMatches=%d,lineArray()=%d', __METHOD__, __LINE__, $expectedMatches, count($lineArray)));
if (($expectedMatches > 0) && (count($lineArray) !== $expectedMatches)) {
// Invalid line found as strict count matching is requested
- throw new UnexpectedValueException(sprintf('lineArray()=%d has not expected count %d', count($lineArray), $expectedMatches));
+ throw new UnexpectedValueException(sprintf('lineArray()=%d has not expected count %d', count($lineArray), $expectedMatches), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
}
// Return it
// Import framework stuff
use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
use Org\Mxchange\CoreFramework\Filesystem\File\BaseAbstractFile;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Output\BaseOutput;
/**
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
*
* @param $fileName File's name
* @return void
+ * @throws InvalidArgumentException If a parameter has an invalid value
*/
- protected function initFile ($fileName) {
+ protected function initFile (string $fileName) {
+ // Check parameter
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-OUTPUT-TEXT-FILE: fileName=%s - CALLED!', $fileName));
+ if (empty($fileName)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "fileName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Get a file i/o pointer instance
- $pointerInstance = ObjectFactory::createObjectByConfiguredName('text_file_output_class', array($fileName));
+ $pointerInstance = ObjectFactory::createObjectByConfiguredName('text_file_output_class', [$fileName]);
// ... and set it here
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-OUTPUT-TEXT-FILE: Setting pointerInstance=%s ...', $pointerInstance->__toString()));
$this->setPointerInstance($pointerInstance);
+
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-OUTPUT-TEXT-FILE: EXIT!');
}
}
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
use Org\Mxchange\CoreFramework\Filter\BaseFilter;
use Org\Mxchange\CoreFramework\Filter\Filterable;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Loader\NoClassException;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
+use Org\Mxchange\CoreFramework\Registry\Object\ObjectRegistry;
use Org\Mxchange\CoreFramework\Request\Requestable;
use Org\Mxchange\CoreFramework\Response\Responseable;
use Org\Mxchange\CoreFramework\User\BaseUser;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
$authInstance->destroyAuthData();
// Mark the request as invalid
- $requestInstance->requestIsValid(false);
+ $requestInstance->setIsRequestValid(FALSE);
// Add fatal message
$responseInstance->addFatalMessage('auth_data_incomplete');
// Does the guest class exist?
if (!class_exists($className)) {
// Then abort here
- throw new NoClassException (array($this, $className), self::EXCEPTION_CLASS_NOT_FOUND);
+ throw new NoClassException ([$this, $className], FrameworkInterface::EXCEPTION_CLASS_NOT_FOUND);
}
// Now try the dynamic login
- $userInstance = call_user_func_array(array($className, $methodName), array($authLogin));
+ $userInstance = call_user_func_array([$className, $methodName], [$authLogin]);
// Is the password correct?
if ($userInstance->getPasswordHash() !== $authHash) {
}
// Remember auth and user instances in registry
- GenericRegistry::getRegistry()->addInstance('auth', $authInstance);
- GenericRegistry::getRegistry()->addInstance('user', $userInstance);
+ ObjectRegistry::getRegistry('generic')->addInstance('auth', $authInstance);
+ ObjectRegistry::getRegistry('generic')->addInstance('user', $userInstance);
}
}
use Org\Mxchange\CoreFramework\Filter\BaseFilter;
use Org\Mxchange\CoreFramework\Filter\Chain\FilterChainException;
use Org\Mxchange\CoreFramework\Filter\Filterable;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
+use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
+use Org\Mxchange\CoreFramework\Registry\Object\ObjectRegistry;
use Org\Mxchange\CoreFramework\Request\Requestable;
use Org\Mxchange\CoreFramework\Response\Responseable;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Is only first email set?
if ((!empty($email1)) && (empty($email2))) {
// Request is invalid!
- $requestInstance->requestIsValid(false);
+ $requestInstance->setIsRequestValid(FALSE);
// Email 2 is empty
$responseInstance->addFatalMessage('email2_empty');
// Is only second email set?
if ((empty($email1)) && (!empty($email2))) {
// Request is invalid!
- $requestInstance->requestIsValid(false);
+ $requestInstance->setIsRequestValid(FALSE);
// Email 1 is empty
$responseInstance->addFatalMessage('email1_empty');
// Do both match?
if ($email1 != $email2) {
// Request is invalid!
- $requestInstance->requestIsValid(false);
+ $requestInstance->setIsRequestValid(FALSE);
// Emails are mismatching
$responseInstance->addFatalMessage('emails_mismatch');
}
// Now, get a user instance for comparison
- $userInstance = GenericRegistry::getRegistry()->getInstance('user');
+ $userInstance = ObjectRegistry::getRegistry('generic')->getInstance('user');
// Get the email field
$userEmail = $userInstance->getField('email');
}
// Update the "new_email" field
- $this->partialStub('Unfinished part.');
+ DebugMiddleware::getSelfInstance()->partialStub('Unfinished part.');
}
}
use Org\Mxchange\CoreFramework\Filter\BaseFilter;
use Org\Mxchange\CoreFramework\Filter\Chain\FilterChainException;
use Org\Mxchange\CoreFramework\Filter\Filterable;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
+use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
+use Org\Mxchange\CoreFramework\Registry\Object\ObjectRegistry;
use Org\Mxchange\CoreFramework\Request\Requestable;
use Org\Mxchange\CoreFramework\Response\Responseable;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Is only first email set?
if ((!empty($pass1)) && (empty($pass2))) {
// Request is invalid!
- $requestInstance->requestIsValid(false);
+ $requestInstance->setIsRequestValid(FALSE);
// Email 2 is empty
$responseInstance->addFatalMessage('pass2_empty');
// Is only second pass set?
if ((empty($pass1)) && (!empty($pass2))) {
// Request is invalid!
- $requestInstance->requestIsValid(false);
+ $requestInstance->setIsRequestValid(FALSE);
// Email 1 is empty
$responseInstance->addFatalMessage('pass1_empty');
// Do both match?
if ($pass1 != $pass2) {
// Request is invalid!
- $requestInstance->requestIsValid(false);
+ $requestInstance->setIsRequestValid(FALSE);
// Emails are mismatching
$responseInstance->addFatalMessage('pass_mismatch');
}
// Now, get a user instance for comparison
- $userInstance = GenericRegistry::getRegistry()->getInstance('user');
+ $userInstance = ObjectRegistry::getRegistry('generic')->getInstance('user');
// Update the "password" field
- $this->partialStub('Unfinished part.');
+ DebugMiddleware::getSelfInstance()->partialStub('Unfinished part.');
}
}
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Was the "rules" value found in form? And is it set?
if (is_null($rules)) {
// Not found in form so stop processing here
- $requestInstance->requestIsValid(false);
+ $requestInstance->setIsRequestValid(FALSE);
// Add a message to the response
$responseInstance->addFatalMessage('rules_unchecked');
// Import framework stuff
use Org\Mxchange\CoreFramework\Filter\BaseFilter;
use Org\Mxchange\CoreFramework\Filter\Filterable;
+use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
use Org\Mxchange\CoreFramework\Request\Requestable;
use Org\Mxchange\CoreFramework\Response\Responseable;
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
*/
public function execute (Requestable $requestInstance, Responseable $responseInstance) {
// Implement this!
- $this->partialStub('Please implement this method.');
+ DebugMiddleware::getSelfInstance()->partialStub('Please implement this method.');
}
}
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Is it there?
if (is_null($encryptRequest)) {
// Not found, so request is invalid
- $requestInstance->requestIsValid(false);
+ $requestInstance->setIsRequestValid(FALSE);
// Throw exception
throw new EncryptMissingException($this, CryptoHelper::EXCEPTION_ENCRYPT_MISSING);
$encryptDecoded = base64_decode(str_replace(' ', '+', urldecode($encryptRequest)));
// Get a crypto helper and decrypt the string
- $decryptedString = ObjectFactory::createObjectByConfiguredName('crypto_class')->decryptString($encryptDecoded);
+ $decryptedString = CryptoHelper::getSelfInstance()->decryptString($encryptDecoded);
// Is it the expected length?
if (strlen($decryptedString) != FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('captcha_string_length')) {
// Not found, so request is invalid
- $requestInstance->requestIsValid(false);
+ $requestInstance->setIsRequestValid(FALSE);
// Throw exception
throw new EncryptInvalidLengthException($this, CryptoHelper::EXCEPTION_ENCRYPT_INVALID);
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
use Org\Mxchange\CoreFramework\Factory\News\HtmlNewsFactory;
use Org\Mxchange\CoreFramework\Filter\BaseFilter;
use Org\Mxchange\CoreFramework\Filter\Filterable;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
+use Org\Mxchange\CoreFramework\Registry\Object\ObjectRegistry;
use Org\Mxchange\CoreFramework\Request\Requestable;
use Org\Mxchange\CoreFramework\Response\Responseable;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
/**
* Creates an instance of this filter class
*
- * @return $filterInstance An instance of this filter class
+ * @return $filterInstance An instance of this filter class
*/
public static final function createNewsDownloadFilter () {
// Get a new instance
$newsInstance = HtmlNewsFactory::createFactoryByRequest($requestInstance);
// Store the news instance in registry
- GenericRegistry::getRegistry()->addInstance('news', $newsInstance);
+ ObjectRegistry::getRegistry('generic')->addInstance('news', $newsInstance);
}
}
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
use Org\Mxchange\CoreFramework\Filter\Filterable;
use Org\Mxchange\CoreFramework\Generic\NullPointerException;
use Org\Mxchange\CoreFramework\Loader\NoClassException;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
+use Org\Mxchange\CoreFramework\Registry\Object\ObjectRegistry;
use Org\Mxchange\CoreFramework\Request\Requestable;
use Org\Mxchange\CoreFramework\Response\Responseable;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Is the resolver set?
if (is_null($resolverInstance)) {
// Throw an exception here
- throw new NullPointerException($filterInstance, self::EXCEPTION_IS_NULL_POINTER);
+ throw new NullPointerException($filterInstance, FrameworkInterface::EXCEPTION_IS_NULL_POINTER);
}
// Get the action name from resolver
$discoveryInstance->discover($requestInstance);
// Remember this instance if all wents fine
- GenericRegistry::getRegistry()->addInstance('payments', $discoveryInstance);
+ ObjectRegistry::getRegistry('generic')->addInstance('payments', $discoveryInstance);
} catch (NoConfigEntryException $e) {
// Something bad happend
- $requestInstance->requestIsValid(false);
+ $requestInstance->setIsRequestValid(FALSE);
// Add a message to the response
$responseInstance->addFatalMessage('payment_config_entry_error');
throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
} catch (NoClassException $e) {
// Something bad happend
- $requestInstance->requestIsValid(false);
+ $requestInstance->setIsRequestValid(FALSE);
// Add a message to the response
$responseInstance->addFatalMessage('payment_class_error');
use Org\Mxchange\CoreFramework\Database\Frontend\User\UserDatabaseFrontend;
use Org\Mxchange\CoreFramework\Filter\BaseFilter;
use Org\Mxchange\CoreFramework\Filter\Filterable;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
+use Org\Mxchange\CoreFramework\Registry\Object\ObjectRegistry;
use Org\Mxchange\CoreFramework\Request\Requestable;
use Org\Mxchange\CoreFramework\Response\Responseable;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*/
public function execute (Requestable $requestInstance, Responseable $responseInstance) {
// Get user instance from registry
- $userInstance = GenericRegistry::getRegistry()->getInstance('user');
+ $userInstance = ObjectRegistry::getRegistry('generic')->getInstance('user');
// Get "confirmed" status from config
$confirmed = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('user_status_confirmed');
// Import framework stuff
use Org\Mxchange\CoreFramework\Filter\BaseFilter;
use Org\Mxchange\CoreFramework\Filter\Filterable;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
+use Org\Mxchange\CoreFramework\Registry\Object\ObjectRegistry;
use Org\Mxchange\CoreFramework\Request\Requestable;
use Org\Mxchange\CoreFramework\Response\Responseable;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*/
public function execute (Requestable $requestInstance, Responseable $responseInstance) {
// Get user instance from registry
- $userInstance = GenericRegistry::getRegistry()->getInstance('user');
+ $userInstance = ObjectRegistry::getRegistry('generic')->getInstance('user');
// Now update last activity
$userInstance->updateLastActivity($requestInstance);
// Update auth data as well
- $authInstance = GenericRegistry::getRegistry()->getInstance('auth');
+ $authInstance = ObjectRegistry::getRegistry('generic')->getInstance('auth');
$authInstance->updateAuthData();
// Write all updates to the database
use Org\Mxchange\CoreFramework\Filter\BaseFilter;
use Org\Mxchange\CoreFramework\Filter\Chain\FilterChainException;
use Org\Mxchange\CoreFramework\Filter\Filterable;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
+use Org\Mxchange\CoreFramework\Registry\Object\ObjectRegistry;
use Org\Mxchange\CoreFramework\Request\Requestable;
use Org\Mxchange\CoreFramework\Response\Responseable;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
$email = $requestInstance->getRequestElement('email');
// Is the Email set?
- if ((is_null($email)) || (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('register_email_unique') == 'Y')) {
+ if ((is_null($email)) || (FrameworkBootstrap::getConfigurationInstance()->isEnabled('register_email_unique'))) {
// Try it again
$email1 = $requestInstance->getRequestElement('email1');
$email2 = $requestInstance->getRequestElement('email2');
// Is the email still not set?
if ((is_null($email1)) || (is_null($email2))) {
// Not found in form so stop the filtering process
- $requestInstance->requestIsValid(false);
+ $requestInstance->setIsRequestValid(FALSE);
// Add a message to the response
$responseInstance->addFatalMessage('email_unset');
throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
} elseif ((empty($email1)) || (empty($email2))) {
// Email is empty
- $requestInstance->requestIsValid(false);
+ $requestInstance->setIsRequestValid(FALSE);
// Is the email empty?
if (empty($email1)) {
throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
} elseif ($this->ifEmailIsTaken($email1)) {
// Email is already taken
- $requestInstance->requestIsValid(false);
+ $requestInstance->setIsRequestValid(FALSE);
// Add a message to the response
$responseInstance->addFatalMessage('email_taken');
throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
} elseif ($email1 != $email2) {
// Emails didn't match
- $requestInstance->requestIsValid(false);
+ $requestInstance->setIsRequestValid(FALSE);
// Add a message to the response
$responseInstance->addFatalMessage('emails_mismatch');
}
} elseif (empty($email)) {
// Empty field!
- $requestInstance->requestIsValid(false);
+ $requestInstance->setIsRequestValid(FALSE);
// Add a message to the response
$responseInstance->addFatalMessage('email_empty');
* @param $email Email to check for existence
* @return $alreadyTaken Whether the email has been taken
*/
- private function ifEmailIsTaken ($email) {
+ private function ifEmailIsTaken (string $email) {
// Default is already taken
$alreadyTaken = true;
$userInstance = NULL;
// Get a registry instance
- $registryInstance = GenericRegistry::getRegistry();
+ $registryInstance = ObjectRegistry::getRegistry('generic');
// Is the user already there?
if ($registryInstance->instanceExists('user')) {
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Is the password still not set?
if ((is_null($password1)) || (is_null($password2))) {
// Not found in form so stop the filtering process
- $requestInstance->requestIsValid(false);
+ $requestInstance->setIsRequestValid(FALSE);
// Add a message to the response
$responseInstance->addFatalMessage('password_unset');
throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
} elseif ((empty($password1)) || (empty($password2))) {
// Password is empty
- $requestInstance->requestIsValid(false);
+ $requestInstance->setIsRequestValid(FALSE);
// Is the password empty?
if (empty($password1)) {
throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
} elseif ($password1 != $password2) {
// Passwords didn't match
- $requestInstance->requestIsValid(false);
+ $requestInstance->setIsRequestValid(FALSE);
// Add a message to the response
$responseInstance->addFatalMessage('pass_mismatch');
use Org\Mxchange\CoreFramework\Filter\BaseFilter;
use Org\Mxchange\CoreFramework\Filter\Chain\FilterChainException;
use Org\Mxchange\CoreFramework\Filter\Filterable;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
+use Org\Mxchange\CoreFramework\Registry\Object\ObjectRegistry;
use Org\Mxchange\CoreFramework\Request\Requestable;
use Org\Mxchange\CoreFramework\Response\Responseable;
use Org\Mxchange\CoreFramework\User\UsernameMissingException;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Is the username set?
if (is_null($userName)) {
// Not found in form so stop the filtering process
- $requestInstance->requestIsValid(false);
+ $requestInstance->setIsRequestValid(FALSE);
// Add a message to the response
$responseInstance->addFatalMessage('username_unset');
throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
} elseif (empty($userName)) {
// Empty field!
- $requestInstance->requestIsValid(false);
+ $requestInstance->setIsRequestValid(FALSE);
// Add a message to the response
$responseInstance->addFatalMessage('username_empty');
throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
} elseif ($this->ifUserNameIsTaken($userName)) {
// Username is already taken
- $requestInstance->requestIsValid(false);
+ $requestInstance->setIsRequestValid(FALSE);
// Add a message to the response
$responseInstance->addFatalMessage('username_taken');
* @param $userName Username to check for existence
* @return $alreadyTaken Whether the username has been taken
*/
- private function ifUserNameIsTaken ($userName) {
+ private function ifUserNameIsTaken (string $userName) {
// Default is already taken
$alreadyTaken = true;
$userInstance = NULL;
// Get a registry instance
- $registryInstance = GenericRegistry::getRegistry();
+ $registryInstance = ObjectRegistry::getRegistry('generic');
// Is the user already there?
if ($registryInstance->instanceExists('user')) {
use Org\Mxchange\CoreFramework\Filter\Chain\FilterChainException;
use Org\Mxchange\CoreFramework\Filter\Filterable;
use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
+use Org\Mxchange\CoreFramework\Helper\Crypto\CryptoHelper;
+use Org\Mxchange\CoreFramework\Registry\Object\ObjectRegistry;
use Org\Mxchange\CoreFramework\Request\Requestable;
use Org\Mxchange\CoreFramework\Response\Responseable;
use Org\Mxchange\CoreFramework\User\BaseUser;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Is the password still not set?
if (is_null($password)) {
// Not found in form so stop the filtering process
- $requestInstance->requestIsValid(false);
+ $requestInstance->setIsRequestValid(FALSE);
// Add a message to the response
$responseInstance->addFatalMessage('password_unset');
if (empty($password)) {
// Password is empty
- $requestInstance->requestIsValid(false);
+ $requestInstance->setIsRequestValid(FALSE);
// Add a message to the response
$responseInstance->addFatalMessage('password_empty');
}
// Get a user instance
- $userInstance = GenericRegistry::getRegistry()->getInstance('user');
+ $userInstance = ObjectRegistry::getRegistry('generic')->getInstance('user');
// Get current hash
$currentHash = $userInstance->getField('pass_hash');
// Get an encryption helper and encrypt the password
- $passHash = ObjectFactory::createObjectByConfiguredName('crypto_class')->hashString($password, $currentHash);
+ $passHash = CryptoHelper::getSelfInstance()->hashString($password, $currentHash);
// Does it match?
if ($currentHash != $passHash) {
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Day of birth set?
if (!$requestInstance->isRequestElementSet('birth_day')) {
// Day of birth isn't set
- $requestInstance->requestIsValid(false);
+ $requestInstance->setIsRequestValid(FALSE);
// Add a message to the response
$responseInstance->addFatalMessage('day_of_birth_unset');
// Month of birth set?
if (!$requestInstance->isRequestElementSet('birth_month')) {
// Month of birth isn't set
- $requestInstance->requestIsValid(false);
+ $requestInstance->setIsRequestValid(FALSE);
// Add a message to the response
$responseInstance->addFatalMessage('month_of_birth_unset');
// Year of birth set?
if (!$requestInstance->isRequestElementSet('birth_year')) {
// Year of birth isn't set
- $requestInstance->requestIsValid(false);
+ $requestInstance->setIsRequestValid(FALSE);
// Add a message to the response
$responseInstance->addFatalMessage('year_of_birth_unset');
// Is there a number or such? (we don't care about the value itself here)
if (empty($birthCheck)) {
// Validation has failed
- $requestInstance->requestIsValid(false);
+ $requestInstance->setIsRequestValid(FALSE);
// Add a message to the response
$responseInstance->addFatalMessage('birthday_invalid');
use Org\Mxchange\CoreFramework\Filter\BaseFilter;
use Org\Mxchange\CoreFramework\Filter\Chain\FilterChainException;
use Org\Mxchange\CoreFramework\Filter\Filterable;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
+use Org\Mxchange\CoreFramework\Registry\Object\ObjectRegistry;
use Org\Mxchange\CoreFramework\Request\Requestable;
use Org\Mxchange\CoreFramework\Response\Responseable;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Is this code set?
if (is_null($confirmCode)) {
// Is not in request
- $requestInstance->requestIsValid(false);
+ $requestInstance->setIsRequestValid(FALSE);
// Add a message to the response
$responseInstance->addFatalMessage('confirm_code_unset');
throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
} elseif (empty($confirmCode)) {
// Email is empty
- $requestInstance->requestIsValid(false);
+ $requestInstance->setIsRequestValid(FALSE);
// Add a message to the response
$responseInstance->addFatalMessage('confirm_code_empty');
}
// Get a user instance from registry
- $userInstance = GenericRegistry::getRegistry()->getInstance('user');
+ $userInstance = ObjectRegistry::getRegistry('generic')->getInstance('user');
// Get the confirm code from user for comparison
$userCode = $userInstance->getField(UserDatabaseFrontend::DB_COLUMN_CONFIRM_HASH);
// Do we have the same code or different?
if ($userCode != $confirmCode) {
// Email is empty
- $requestInstance->requestIsValid(false);
+ $requestInstance->setIsRequestValid(FALSE);
// Redirect to error page
$responseInstance->redirectToConfiguredUrl('confirm_code_invalid');
use Org\Mxchange\CoreFramework\Filter\BaseFilter;
use Org\Mxchange\CoreFramework\Filter\Chain\FilterChainException;
use Org\Mxchange\CoreFramework\Filter\Filterable;
+use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
use Org\Mxchange\CoreFramework\Request\Requestable;
use Org\Mxchange\CoreFramework\Response\Responseable;
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
*/
public function execute (Requestable $requestInstance, Responseable $responseInstance) {
// Implement this!
- $this->partialStub('Please implement this method.');
+ DebugMiddleware::getSelfInstance()->partialStub('Please implement this method.');
}
}
use Org\Mxchange\CoreFramework\Filter\BaseFilter;
use Org\Mxchange\CoreFramework\Filter\Chain\FilterChainException;
use Org\Mxchange\CoreFramework\Filter\Filterable;
+use Org\Mxchange\CoreFramework\Helper\Crypto\CryptoHelper;
use Org\Mxchange\CoreFramework\Request\Requestable;
use Org\Mxchange\CoreFramework\Response\Responseable;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Is the form set?
if (($requestInstance->getRequestElement('command') !== 'do_form') || (!$requestInstance->isRequestElementSet('form'))) {
// Required field not set
- $requestInstance->requestIsValid(false);
+ $requestInstance->setIsRequestValid(FALSE);
// Add fatal message
$responseInstance->addFatalMessage('command_form_invalid');
}
// Create config entry
- $configKey = sprintf('%s_captcha_secured',
- $requestInstance->getRequestElement('form')
- );
+ $configKey = sprintf('%s_captcha_secured', $requestInstance->getRequestElement('form'));
// Is the CAPTCHA enabled?
- if (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry($configKey) != 'Y') {
+ if (FrameworkBootstrap::getConfigurationInstance()->isEnabled($configKey)) {
// Not enabled, so don't check
return;
}
// Is this set?
if (is_null($captchaCode)) {
// Not set so request is invalid
- $requestInstance->requestIsValid(false);
+ $requestInstance->setIsRequestValid(FALSE);
// Add fatal message
$responseInstance->addFatalMessage('captcha_code_unset');
throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
} elseif (empty($captchaCode)) {
// Empty value so request is invalid
- $requestInstance->requestIsValid(false);
+ $requestInstance->setIsRequestValid(FALSE);
// Add fatal message
$responseInstance->addFatalMessage('captcha_code_empty');
// Is this set?
if (is_null($captchaHash)) {
// Not set so request is invalid
- $requestInstance->requestIsValid(false);
+ $requestInstance->setIsRequestValid(FALSE);
// Add fatal message
$responseInstance->addFatalMessage('captcha_hash_unset');
throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
} elseif (empty($captchaHash)) {
// Empty value so request is invalid
- $requestInstance->requestIsValid(false);
+ $requestInstance->setIsRequestValid(FALSE);
// Add fatal message
$responseInstance->addFatalMessage('captcha_hash_empty');
}
// Now, both are set hash the given one. First get a crypto instance
- $cryptoInstance = ObjectFactory::createObjectByConfiguredName('crypto_class');
+ $cryptoInstance = CryptoHelper::getSelfInstance();
// Then hash the code
$hashedCode = $cryptoInstance->hashString($captchaCode, $captchaHash);
// Is this CAPTCHA valid?
if ($hashedCode != $captchaHash) {
// Not the same so request is invalid
- $requestInstance->requestIsValid(false);
+ $requestInstance->setIsRequestValid(FALSE);
// Add fatal message
$responseInstance->addFatalMessage('captcha_hash_mismatch');
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Is the password still not set?
if (is_null($password)) {
// Not found in form so stop the filtering process
- $requestInstance->requestIsValid(false);
+ $requestInstance->setIsRequestValid(FALSE);
// Add a message to the response
$responseInstance->addFatalMessage('password_unset');
throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
} elseif (empty($password)) {
// Password is empty
- $requestInstance->requestIsValid(false);
+ $requestInstance->setIsRequestValid(FALSE);
// Add a message to the response
$responseInstance->addFatalMessage('password_empty');
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Is the password still not set?
if (is_null($password)) {
// Not found in form so stop the filtering process
- $requestInstance->requestIsValid(false);
+ $requestInstance->setIsRequestValid(FALSE);
// Add a message to the response
$responseInstance->addFatalMessage('password_unset');
throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
} elseif (empty($password)) {
// Password is empty
- $requestInstance->requestIsValid(false);
+ $requestInstance->setIsRequestValid(FALSE);
// Add a message to the response
$responseInstance->addFatalMessage('password_empty');
use Org\Mxchange\CoreFramework\Filter\BaseFilter;
use Org\Mxchange\CoreFramework\Filter\Chain\FilterChainException;
use Org\Mxchange\CoreFramework\Filter\Filterable;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
+use Org\Mxchange\CoreFramework\Registry\Object\ObjectRegistry;
use Org\Mxchange\CoreFramework\Request\Requestable;
use Org\Mxchange\CoreFramework\Response\Responseable;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Is the username set?
if (is_null($userName)) {
// Not found in form so stop the filtering process
- $requestInstance->requestIsValid(false);
+ $requestInstance->setIsRequestValid(FALSE);
// Add a message to the response
$responseInstance->addFatalMessage('username_guest_unset');
throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
} elseif (empty($userName)) {
// Empty field!
- $requestInstance->requestIsValid(false);
+ $requestInstance->setIsRequestValid(FALSE);
// Add a message to the response
$responseInstance->addFatalMessage('username_guest_empty');
throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
} elseif ($this->ifUserGuestIsTaken($userName) === false) {
// Username is already taken
- $requestInstance->requestIsValid(false);
+ $requestInstance->setIsRequestValid(FALSE);
// Add a message to the response
$responseInstance->addFatalMessage('username_guest_not_found');
* @param $userName Username to check for existence
* @return $alreadyTaken Whether the username has been taken
*/
- private function ifUserGuestIsTaken ($userName) {
+ private function ifUserGuestIsTaken (string $userName) {
// Default is already taken
$alreadyTaken = true;
$userInstance = NULL;
// Get a registry instance
- $registryInstance = GenericRegistry::getRegistry();
+ $registryInstance = ObjectRegistry::getRegistry('generic');
// Is the user already there?
if ($registryInstance->instanceExists('user')) {
use Org\Mxchange\CoreFramework\Filter\BaseFilter;
use Org\Mxchange\CoreFramework\Filter\Chain\FilterChainException;
use Org\Mxchange\CoreFramework\Filter\Filterable;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
+use Org\Mxchange\CoreFramework\Registry\Object\ObjectRegistry;
use Org\Mxchange\CoreFramework\Request\Requestable;
use Org\Mxchange\CoreFramework\Response\Responseable;
use Org\Mxchange\CoreFramework\User\UsernameMissingException;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Is the username set?
if (is_null($userName)) {
// Not found in form so stop the filtering process
- $requestInstance->requestIsValid(false);
+ $requestInstance->setIsRequestValid(FALSE);
// Add a message to the response
$responseInstance->addFatalMessage('username_unset');
throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
} elseif (empty($userName)) {
// Empty field!
- $requestInstance->requestIsValid(false);
+ $requestInstance->setIsRequestValid(FALSE);
// Add a message to the response
$responseInstance->addFatalMessage('username_empty');
throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
} elseif ($this->ifUserNameIsTaken($userName) === false) {
// Username is already taken
- $requestInstance->requestIsValid(false);
+ $requestInstance->setIsRequestValid(FALSE);
// Add a message to the response
$responseInstance->addFatalMessage('username_not_found');
* @param $userName Username to check for existence
* @return $alreadyTaken Whether the username has been taken
*/
- private function ifUserNameIsTaken ($userName) {
+ private function ifUserNameIsTaken (string $userName) {
// Default is already taken
$alreadyTaken = true;
$userInstance = NULL;
// Get a registry instance
- $registryInstance = GenericRegistry::getRegistry();
+ $registryInstance = ObjectRegistry::getRegistry('generic');
// Is the user already there?
if ($registryInstance->instanceExists('user')) {
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
use Org\Mxchange\CoreFramework\Filter\BaseFilter;
use Org\Mxchange\CoreFramework\Filter\Filterable;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
+use Org\Mxchange\CoreFramework\Registry\Object\ObjectRegistry;
use Org\Mxchange\CoreFramework\Request\Requestable;
use Org\Mxchange\CoreFramework\Response\Responseable;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*/
public function execute (Requestable $requestInstance, Responseable $responseInstance) {
// Get a user instance for comparison
- $userInstance = GenericRegistry::getRegistry()->getInstance('user');
+ $userInstance = ObjectRegistry::getRegistry('generic')->getInstance('user');
// Is the user account confirmed?
if ((!$userInstance->isConfirmed()) && (!$userInstance->isGuest()) && ($requestInstance->getRequestElement('action') != FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('action_status_problem'))) {
// Request is invalid!
- $requestInstance->requestIsValid(false);
+ $requestInstance->setIsRequestValid(FALSE);
// Redirect to configured URL
$responseInstance->redirectToConfiguredUrl('login_user_status');
use Org\Mxchange\CoreFramework\Factory\User\UserFactory;
use Org\Mxchange\CoreFramework\Filter\BaseFilter;
use Org\Mxchange\CoreFramework\Filter\Filterable;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
+use Org\Mxchange\CoreFramework\Registry\Object\ObjectRegistry;
use Org\Mxchange\CoreFramework\Request\Requestable;
use Org\Mxchange\CoreFramework\Response\Responseable;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Is the email address valid?
if ($userInstance->ifEmailAddressExists() === false) {
// Request is invalid!
- $requestInstance->requestIsValid(false);
+ $requestInstance->setIsRequestValid(FALSE);
// Redirect to configured URL
$responseInstance->redirectToConfiguredUrl('user_unconfirmed_email_missing');
// Is the user account confirmed?
if ($userInstance->getField(UserDatabaseFrontend::DB_COLUMN_USER_STATUS) != FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('user_status_unconfirmed')) {
// Request is invalid!
- $requestInstance->requestIsValid(false);
+ $requestInstance->setIsRequestValid(FALSE);
// Redirect to configured URL
$responseInstance->redirectToConfiguredUrl('user_not_unconfirmed');
}
// Add this instance to registry
- GenericRegistry::getRegistry()->addInstance('user', $userInstance);
+ ObjectRegistry::getRegistry('generic')->addInstance('user', $userInstance);
}
}
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
// Import framework stuff
use Org\Mxchange\CoreFramework\Criteria\Storing\StoreableCriteria;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Handler\DataSet\HandleableDataSet;
use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
+// Import SPL stuff
+use \InvalidArgumentException;
+
/**
* A general Handler
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*/
protected function __construct (string $className) {
// Call parent constructor
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-HANDLER: className=%s - CONSTRUCTED!', $className));
parent::__construct($className);
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-HANDLER: EXIT!');
}
/**
* @todo Rewrite this to use DHT
*/
public function addArrayToDataSet (StoreableCriteria $dataSetInstance, array $messageData) {
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-HANDLER: dataSetInstance=%s,messageData()=%d - CALLED!', $dataSetInstance->__toString(), count($messageData)));
+ if (count($messageData) == 0) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "messageData" is an empty array', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-HANDLER: EXIT!');
}
}
// Import framework stuff
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Handler\BaseHandler;
use Org\Mxchange\CoreFramework\Registry\Registerable;
use Org\Mxchange\CoreFramework\Task\Taskable;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*/
private function __construct () {
// Call parent constructor
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('TASK-HANDLER: CONSTRUCTWD!');
parent::__construct(__CLASS__);
// Set handler name
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('TASK-HANDLER: Setting handlerName=task ...');
$this->setHandlerName('task');
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('TASK-HANDLER: EXIT!');
}
/**
*/
public static final function createTaskHandler () {
// Get new instance
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('TASK-HANDLER: CALLED!');
$handlerInstance = new TaskHandler();
// Output debug message
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TASK-HANDLER: Initializing task handler.');
+ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('TASK-HANDLER: Initializing task handler.');
// Init the task list
$handlerInstance->setListInstance(ObjectFactory::createObjectByConfiguredName('task_list_class'));
$handlerInstance->registerTask('idle_loop', $taskInstance);
// Output debug message
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TASK-HANDLER: Task handler initialized.');
+ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('TASK-HANDLER: Task handler initialized.');
// Return the prepared instance
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('TASK-HANDLER:handlerInstance=%s - EXIT!', $handlerInstance->__toString()));
return $handlerInstance;
}
*/
private function executeCurrentTask () {
// Update no task by default
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('TASK-HANDLER: CALLED!');
$updateTask = false;
// Is the current task valid?
$currentTask = $this->getListInstance()->getIterator()->current();
// Is the task not yet started?
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('TASK-HANDLER: currentTask()=%d', count($currentTask)));
if ($currentTask['task_started'] === false) {
// Determine difference between current time and registration
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('TASK-HANDLER: currentTask[id]=%s has not started yet, checking ...', $currentTask['id']));
$diff = ($this->getMilliTime() - $currentTask['task_registered']) * 1000;
// Should we start now?
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('TASK-HANDLER: diff=%d,currentTask[task_startup_delay]=%d', $diff, $currentTask['task_startup_delay']));
if ($diff < $currentTask['task_startup_delay']) {
// Skip this silently
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TASK-HANDLER: Task ' . $currentTask['id'] . ' not started: diff=' . $diff . ',task_startup_delay=' . $currentTask['task_startup_delay']);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('TASK-HANDLER: Task %s not started: diff=%d,task_startup_delay=%d', $currentTask['id'], $diff, $currentTask['task_startup_delay']));
return;
}
$updateTask = true;
// Debug message
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TASK-HANDLER: Task ' . $currentTask['id'] . ' started with startup_delay=' . $currentTask['task_startup_delay'] . 'ms');
+ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('TASK-HANDLER: Task %s started with startup_delay=%dms', $currentTask['id'], $currentTask['task_startup_delay']));
}
// Get time difference from interval delay
$diff = ($this->getMilliTime() - $currentTask['task_last_activity']) * 1000;
// Is the interval delay reached?
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TASK-HANDLER: Task ' . $currentTask['id'] . ' diff=' . $diff . ',task_interval_delay=' . $currentTask['task_interval_delay'] . ',task_max_runs=' . $currentTask['task_max_runs'] . ',task_total_runs=' . $currentTask['task_total_runs']);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('TASK-HANDLER: Task ' . $currentTask['id'] . ' diff=' . $diff . ',task_interval_delay=' . $currentTask['task_interval_delay'] . ',task_max_runs=' . $currentTask['task_max_runs'] . ',task_total_runs=' . $currentTask['task_total_runs']);
if ((($diff < $currentTask['task_interval_delay']) && ($currentTask['task_max_runs'] == 0)) || (($currentTask['task_max_runs'] > 0) && ($currentTask['task_total_runs'] == $currentTask['task_max_runs']))) {
// Should we update the task from startup?
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('TASK-HANDLER: currentTask[id]=%s has reached interval ... updateTask=%d', $currentTask['id'], intval($updateTask)));
if ($updateTask === true) {
// Update the task before leaving
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('TASK-HANDLER: Updating task %s ...', $currentTask['id']));
$this->updateTask($currentTask);
}
// Skip this silently
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('TASK-HANDLER: Task %s has been updated - EXIT!', $currentTask['id']));
return;
}
$currentTask['task_total_runs']++;
// Update the task
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('TASK-HANDLER: Updating task %s ...', $currentTask['id']));
$this->updateTask($currentTask);
// And visit/run it
// @TODO Messurement can be added around this call
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('TASK-HANDLER: Invoking currentTask[task_instance]->accept(%s), task_instance=%s ...', $this->getVisitorInstance()->__toString(), $currentTask['task_instance']->__toString()));
$currentTask['task_instance']->accept($this->getVisitorInstance());
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('TASK-HANDLER: EXIT!');
}
/**
*/
private function updateTask (array $taskEntry) {
// Get the key from current iteration
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('TASK-HANDLER: taskEntry()=%d - CALLED!', count($taskEntry)));
$key = $this->getListInstance()->getIterator()->key();
// Get the hash from key
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('TASK-HANDLER: key=%s', $key));
$hash = $this->getListInstance()->getHashByIndex($key);
// Update the entry
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('TASK-HANDLER: Invoking this->listInstance->updateCurrentEntryByHash(%s,taskEntry()=%d) ...', $hash, count($taskEntry)));
$this->getListInstance()->updateCurrentEntryByHash($hash, $taskEntry);
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('TASK-HANDLER: EXIT!');
}
/**
* @return void
*/
private function unregisterTask (array $taskData) {
- // Debug output
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TASK-HANDLER: Removing task ' . $taskData['id'] . ' from queue - CALLED!');
-
// Remove the entry
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('TASK-HANDLER: Removing task %s from queue - CALLED!', $taskData['id']));
$this->getListInstance()->removeEntry('tasks', $taskData);
- // Debug output
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TASK-HANDLER: Removing task ' . $taskData['id'] . ' from queue - EXIT!');
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('TASK-HANDLER: Removing task %s from queue - EXIT!', $taskData['id']));
}
/**
*/
public function searchTask (Taskable $taskInstance) {
// Default is an empty (not found) task name
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('TASK-HANDLER: taskInstance=%s - CALLED!', $taskInstance->__toString()));
$taskName = '';
// Get whole list
$taskList = $this->getListInstance()->getArrayFromList('tasks');
// Search all instances
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('TASK-HANDLER: taskList()=%d', count($taskList)));
foreach ($taskList as $currentTask) {
// Does it match given task instance?
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('TASK-HANDLER: currentTask[id=%s', $currentTask['id']));
if ($currentTask['task_instance']->equals($taskInstance)) {
// Found it
$taskName = $currentTask['id'];
// Abort here
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('TASK-HANDLER: taskName=%s - BREAK!', $taskName));
break;
}
}
// Return found name
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('TASK-HANDLER: taskName=%s - EXIT!', $taskName));
return $taskName;
}
*/
public function registerTask (string $taskName, Taskable $taskInstance) {
// Is the parameter valid
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('TASK-HANDLER: taskName=%s,taskInstance - CALLED!', $taskName, $taskInstance->__toString()));
if (empty($taskName)) {
// Task name cannot be empty
- throw new InvalidArgumentException('Parameter "taskName" is empty');
+ throw new InvalidArgumentException('Parameter "taskName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
}
// Get interval delay, startup delay and max runs
$maxRuns = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('task_' . $taskName . '_max_runs');
// If the task is 'idle_loop', a deplay of zero seconds is fine
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('TASK-HANDLER: intervalDelay=%d,startupDelay=%d,maxRuns=%d', $intervalDelay, $startupDelay, $maxRuns));
if ($intervalDelay < 0) {
// Invalid configuration value
- throw new UnexpectedValueException(sprintf('taskName=%s has intervalDelay=%d below zero', $taskName, $intervalDelay));
+ throw new UnexpectedValueException(sprintf('taskName=%s has intervalDelay=%d below zero', $taskName, $intervalDelay), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
} elseif ($startupDelay < 0) {
// Invalid configuration value
- throw new UnexpectedValueException(sprintf('taskName=%s has startupDelay=%d below zero', $taskName, $startupDelay));
+ throw new UnexpectedValueException(sprintf('taskName=%s has startupDelay=%d below zero', $taskName, $startupDelay), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
} elseif ($maxRuns < 0) {
// Invalid configuration value
- throw new UnexpectedValueException(sprintf('taskName=%s has maxRuns=%d below zero', $taskName, $maxRuns));
+ throw new UnexpectedValueException(sprintf('taskName=%s has maxRuns=%d below zero', $taskName, $maxRuns), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
} elseif ($taskName != 'idle_loop' && $intervalDelay == 0) {
// Only idle_loop can have a zero interval delay
- throw new UnexpectedValueException(sprintf('taskName=%s has zero interval delay which is only valid for "idle_loop" task', $taskName));
+ throw new UnexpectedValueException(sprintf('taskName=%s has zero interval delay which is only valid for "idle_loop" task', $taskName), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
} elseif ($taskName != 'idle_loop' && $startupDelay == 0) {
// Only idle_loop can have a zero interval delay
- throw new UnexpectedValueException(sprintf('taskName=%s has zero startup delay which is only valid for "idle_loop" task', $taskName));
+ throw new UnexpectedValueException(sprintf('taskName=%s has zero startup delay which is only valid for "idle_loop" task', $taskName), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
}
// Create the entry
];
// Add the entry
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('TASK-HANDLER: Invoking this->listInstance->addEntry(tasks,taskEntry()=%d) ...', count($taskEntry)));
$this->getListInstance()->addEntry('tasks', $taskEntry);
// Debug message
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TASK-HANDLER: Task registered: taskName=' . $taskName .
- ' (taskInstance=' . $taskInstance->__toString() . ')' .
- ', startupDelay=' . $taskEntry['task_startup_delay'] . 'ms' .
- ', intervalDelay=' . $taskEntry['task_interval_delay'] . 'ms' .
- ', maxRuns=' . $taskEntry['task_max_runs'] . ' ...'
- );
+ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('TASK-HANDLER: Task registered: taskName=%s (taskInstance=%s), startupDelay=%dms, intervalDelay=%dms, maxRuns=%d ...',
+ $taskName,
+ $taskInstance->__toString(),
+ $taskEntry['task_startup_delay'],
+ $taskEntry['task_interval_delay'],
+ $taskEntry['task_max_runs'],
+ ));
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('TASK-HANDLER: EXIT!');
}
/**
*/
public function hasTasksLeft () {
// Do we have tasks there?
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('TASK-HANDLER: CALLED!');
$tasksLeft = ($this->getListInstance()->count() > 0);
// Return result
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('TASK-HANDLER: tasksLeft=%d - EXIT!', intval($tasksLeft)));
return $tasksLeft;
}
*/
public function handleTasks () {
// Should we rewind?
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('TASK-HANDLER: CALLED!');
if (!$this->getListInstance()->getIterator()->valid()) {
// Rewind to the beginning for next loop
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('TASK-HANDLER: Invoking this->listInstance->iterator->rewind() ...');
$this->getListInstance()->getIterator()->rewind();
}
// Try to execute the task
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('TASK-HANDLER: Invoking this->executeCurrentTask() ...');
$this->executeCurrentTask();
// Go to next entry
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('TASK-HANDLER: Invoking this->listInstance->iterator->next() ...');
$this->getListInstance()->getIterator()->next();
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('TASK-HANDLER: EXIT!');
}
/**
*/
public function doShutdown () {
// Always rewind to the beginning for next loop
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('TASK-HANDLER: Invoking this->listInstance->iterator->rewind() - CALLED!');
$this->getListInstance()->getIterator()->rewind();
- // Debug message
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TASK-HANDLER: Shutting down all ' . $this->getListInstance()->count() . ' tasks...');
-
// Remember all tasks that has been shutdown for removal
+ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('TASK-HANDLER: Shutting down all %d tasks...', $this->getListInstance()->count()));
$tasks = [];
// Instance a visitor
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('TASK-HANDLER: Setting visitorInstance=shutdown_task_visitor_class from configuration ...');
$this->setVisitorInstance(ObjectFactory::createObjectByConfiguredName('shutdown_task_visitor_class'));
// Shutdown all tasks in once go
// Get current entry
$currentTask = $this->getListInstance()->getIterator()->current();
- // Output debug message
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TASK-HANDLER: Shutting down task ' . $currentTask['id'] . ' (taskInstance=' . $currentTask['task_instance']->__toString() . ') ...');
-
// Shutdown the task
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('TASK-HANDLER: Shutting down task ' . $currentTask['id'] . ' (taskInstance=' . $currentTask['task_instance']->__toString() . ') ...');
$currentTask['task_instance']->accept($this->getVisitorInstance());
// Remember this task
array_push($tasks, $currentTask);
// Advance to next one
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('TASK-HANDLER: Invoking this->listInstance->iterator->next() ...');
$this->getListInstance()->getIterator()->next();
}
- // Debug message
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TASK-HANDLER: Shutdown of all tasks completed.');
-
// Remove all tasks
- foreach ($tasks as $entry) {
- $this->unregisterTask($entry);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('TASK-HANDLER: Shutdown of all tasks completed. tasks()=%d', count($tasks)));
+ foreach ($tasks as $taskEntry) {
+ // Unregister this task
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('TASK-HANDLER: Invokint this->unregisterTask(taskEntry()=%d) ...', count($taskEntry)));
+ $this->unregisterTask($taskEntry);
}
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('TASK-HANDLER: EXIT!');
}
}
// Import framework stuff
use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
+use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
/**
* A solveable CAPTCHA
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
* @todo 0% done
*/
public function initiateCaptcha () {
- $this->partialStub("Please implement this method.");
+ DebugMiddleware::getSelfInstance()->partialStub("Please implement this method.");
}
/**
* @todo 0% done
*/
public function renderCode () {
- $this->partialStub("Please implement this method.");
+ DebugMiddleware::getSelfInstance()->partialStub("Please implement this method.");
}
}
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
+use Org\Mxchange\CoreFramework\Helper\Crypto\CryptoHelper;
use Org\Mxchange\CoreFramework\Helper\Template\HelpableTemplate;
/**
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
}
// Get crypto instance
- $cryptoInstance = ObjectFactory::createObjectByConfiguredName('crypto_class');
+ $cryptoInstance = CryptoHelper::getSelfInstance();
// Hash the CAPTCHA code for later comparison
$this->hashedString = $cryptoInstance->hashString($captchaString);
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Generic\NullPointerException;
use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
+use Org\Mxchange\CoreFramework\Registry\Object\ObjectRegistry;
use Org\Mxchange\CoreFramework\Utils\Strings\StringUtils;
+// Import SPL stuff
+use \BasMethodCallException;
+use \InvalidArgumentException;
+
/**
* A generic helper class with generic methods
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
private $totalCounter = 0;
// Exception constants
- const EXCEPTION_GROUP_NOT_OPENED = 0x1e3;
- const EXCEPTION_GROUP_ALREADY_FOUND = 0x1e4;
- const EXCEPTION_SUB_GROUP_ALREADY_FOUND = 0x1e5;
- const EXCEPTION_NO_PREVIOUS_SUB_GROUP_OPENED = 0x1e6;
- const EXCEPTION_NO_PREVIOUS_GROUP_OPENED = 0x1e7;
+ const EXCEPTION_GROUP_NOT_OPENED = 0x1e0;
+ const EXCEPTION_SUB_GROUP_ALREADY_FOUND = 0x1e1;
+ const EXCEPTION_NO_PREVIOUS_SUB_GROUP_OPENED = 0x1e2;
+ const EXCEPTION_NO_PREVIOUS_GROUP_OPENED = 0x1e3;
/**
* Protected constructor
*/
protected function __construct (string $className) {
// Call parent constructor
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-HELPER: className=%s - CONSTRUCTED!', $className));
parent::__construct($className);
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-HELPER: EXIT!');
}
/**
*
* @param $newContent New content to add
* @return void
+ * @throws InvalidArgumentException If a parameter has an invalid value
*/
protected final function addContent (string $newContent) {
+ // Check variable
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-HELPER: newContent=%s - CALLED!', $newContent));
+ if (empty(trim($newContent))) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "newContent" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
+ // Append content with EOL
$this->content .= trim($newContent) . PHP_EOL;
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-HELPER: this->content()=%d - EXIT!', strlen($this->content)));
}
/**
*
* @param $content Content to to the base
* @return void
+ * @throws InvalidArgumentException If a parameter has an invalid value
*/
protected function addHeaderContent (string $content) {
+ // Check variable
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-HELPER: content=%s - CALLED!', $content));
+ if (empty(trim($content))) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "content" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Add the header content
$this->groups['header']['content'] = trim($content);
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-HELPER: EXIT!');
}
/**
*
* @param $content Content to to the base
* @return void
+ * @throws InvalidArgumentException If a parameter has an invalid value
*/
protected function addFooterContent (string $content) {
+ // Check variable
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-HELPER: content=%s - CALLED!', $content));
+ if (empty(trim($content))) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "content" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Add the footer content
$this->groups['footer']['content'] = trim($content);
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-HELPER: EXIT!');
}
/**
*
* @param $newContent New content to add
* @return void
+ * @throws InvalidArgumentException If a parameter has an invalid value
*/
protected final function addContentToPreviousGroup (string $newContent) {
+ // Check on parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: newContent=%s - CALLED!', $newContent));
+ if (empty($newContent)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "newContent" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Check for sub/group
if ($this->ifSubGroupOpenedPreviously()) {
// Get sub group id
// Add it directly
$this->addContent($newContent);
}
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-HELPER: EXIT!');
}
/**
*
* @param $fieldName Name of the field to assign
* @return void
+ * @throws InvalidArgumentException If a parameter has an invalid value
*/
public function assignField (string $fieldName) {
+ // Check on parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: fieldName=%s - CALLED!', $fieldName));
+ if (empty($fieldName)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "fieldName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Get the value from value instance
$fieldValue = $this->getValueField($fieldName);
// Assign it with a template variable
$this->getTemplateInstance()->assignVariable('block_' . $fieldName, $fieldValue);
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-HELPER: EXIT!');
}
/**
* @param $fieldName Name of the field to assign
* @param $filterMethod Method name to call of the value instance
* @return void
+ * @throws InvalidArgumentException If a parameter has an invalid value
* @todo Rewrite this method using a helper class for filtering data
*/
public function assignFieldWithFilter (string $fieldName, string $filterMethod) {
+ // Validate parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: fieldName=%s,filterMethod=%s - CALLED!', $fieldName, $filterMethod));
+ if (empty($fieldName)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "fieldName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($filterMethod)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "filterMethod" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Get the value
$fieldValue = $this->getValueField($fieldName);
- //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput($fieldName.'='.$fieldValue);
// Now filter it through the value through the filter method
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: %s[%s]=%s', $fieldName, gettype($fieldValue), $fieldValue));
$filteredValue = call_user_func_array(array($this, 'doFilter' . StringUtils::convertToClassName($filterMethod)), array($fieldValue));
// Assign it with a template variable
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: filteredValue[%s]=%s', gettype($filteredValue), $filteredValue));
$this->getTemplateInstance()->assignVariable('block_' . $fieldName, $filteredValue);
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-HELPER: EXIT!');
}
/**
* @param $registryKey Registry key which holds an object with values
* @param $extraKey Extra value instance key used if registryKey is null
* @return void
- * @throws NullPointerException If recovery of requested value instance failed
+ * @throws InvalidArgumentException If a parameter has an invalid value
*/
public function prefetchValueInstance (string $registryKey, string $extraKey = NULL) {
// Validate parameter
- //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('O:'.$registryKey.'/'.$extraKey);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: registryKey=%s,extraKey[%s]=%s - CALLED!', $registryKey, gettype($extraKey), $extraKey));
if (empty($registryKey)) {
// Throw IAE
- throw new InvalidArgumentException('Parameter "registryKey" is empty');
+ throw new InvalidArgumentException('Parameter "registryKey" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
}
try {
// Get the required instance
- $this->valueInstance = GenericRegistry::getRegistry()->getInstance($registryKey);
+ $this->valueInstance = ObjectRegistry::getRegistry('generic')->getInstance($registryKey);
} catch (NullPointerException $e) {
// Not set in registry
- // @TODO Try to log it here
- //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput($registryKey.'=NULL!');
+ //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: registryKey=%s returned no instance (NPE thrown)', $registryKey));
}
// Shall we get an extra instance?
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: extraKey[%s]=%s', gettype($extraKey), $extraKey));
if (!is_null($extraKey)) {
try {
// Get the extra instance.
- $this->extraInstance = GenericRegistry::getRegistry()->getInstance($extraKey);
+ $this->extraInstance = ObjectRegistry::getRegistry('generic')->getInstance($extraKey);
} catch (NullPointerException $e) {
// Try to create it
- $this->extraInstance = ObjectFactory::createObjectByConfiguredName($extraKey . '_class', array($this->valueInstance));
+ //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: extraKey=%s returned no instance (NPE thrown), this->valueInstance[]=%s', $extraKey, gettype($this->valueInstance)));
+ $this->extraInstance = ObjectFactory::createObjectByConfiguredName($extraKey . '_class', [$this->valueInstance]);
}
- //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput($extraKey.'='.$this->extraInstance.' - EXTRA!');
+ //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: extraKey=%s,this->extraInstance[%s]=%s', $extraKey, gettype($this->extraInstance), $this->extraInstance));
}
// Is the value instance valid?
+ //* NOSIY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: this->valueInstance[]=%s - BEFORE!', gettype($this->valueInstance)));
if (is_null($this->valueInstance)) {
// Get the requested instance
$this->valueInstance = ObjectFactory::createObjectByConfiguredName($registryKey . '_class', array($this->extraInstance));
}
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: this->valueInstance[]=%s - AFTER/EXIT!', gettype($this->valueInstance)));
}
/**
* @param $content Initial content to add to the group
* @param $tag HTML tag used to open this group
* @return void
- * @throws HelperGroupAlreadyCreatedException If the group was already created before
+ * @throws InvalidArgumentException If a parameter has an invalid value
+ * @throws BadMethodCallException If the group was already created before
*/
protected function openGroupByIdContent (string $groupId, string $content, string $tag) {
// Is the group already there?
- //* DEBUG: */ echo "OPEN:groupId={$groupId},content=<pre>".htmlentities($content)."</pre>\n";
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: groupdId=%s,content=%s,tag=%s - CALLED!', $groupdId, $content, $tag));
if (empty($groupId)) {
// Throw IAE
- throw new InvalidArgumentException('Parameter "groupId" is empty');
+ throw new InvalidArgumentException('Parameter "groupId" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif (isset($this->groups[$groupId])) {
// Then throw an exception here
- throw new HelperGroupAlreadyCreatedException(array($this, $groupId), self::EXCEPTION_GROUP_ALREADY_FOUND);
+ throw new BadMethodCallException(sprintf('[%s:%d]: groupId=%s is already opened.', $this->__toString(), $groupId), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
+ } elseif (empty($content)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "content" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($tag)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "tag" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
}
// Count one up
$this->totalCounter++;
// Add the group to the stack
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: this->totalCounter=%d', $this->totalCounter));
$this->groups[$this->totalCounter] = $groupId;
$this->groups[$groupId]['opened'] = true;
$this->groups[$groupId]['content'] = sprintf(
$this->groups[$groupId]['tag'] = $tag;
// Mark this group as previously opened
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: Setting this->previousGroupId=%s ...', $groupId));
$this->setPreviousGroupId($groupId);
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-HELPER: EXIT!');
}
/**
*/
public function closePreviousGroupByContent (string $content = '') {
// Check if any sub group was opened before
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: content(%d)=%s - CALLED!', strlen($content), $content));
if ($this->ifSubGroupOpenedPreviously()) {
// Close it automatically
$this->closePreviousSubGroupByContent();
// Mark previous group as closed
$this->setPreviousGroupId('');
- //* DEBUG: */ echo "CLOSE:groupId={$groupId}<br />\n";
+ //* NOISY-DEBUG: */ echo "CLOSE:groupId={$groupId}<br />\n";
}
/**
* @throws HelperSubGroupAlreadyCreatedException If the sub group was already created before
*/
protected function openSubGroupByIdContent (string $subGroupId, string $content, string $tag) {
- //* DEBUG: */ echo "OPEN:subGroupId={$subGroupId},content=".htmlentities($content)."<br />\n";
+ //* NOISY-DEBUG: */ echo "OPEN:subGroupId={$subGroupId},content=".htmlentities($content)."<br />\n";
// Is the group already there?
if (empty($subGroupId)) {
// Throw IAE
- throw new InvalidArgumentException('Parameter "subGroupId" is empty');
+ throw new InvalidArgumentException('Parameter "subGroupId" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif (isset($this->subGroups[$subGroupId])) {
// Then throw an exception here
throw new HelperSubGroupAlreadyCreatedException(array($this, $subGroupId), self::EXCEPTION_SUB_GROUP_ALREADY_FOUND);
// Mark previous sub group as closed
$this->setPreviousSubGroupId('');
- //* DEBUG: */ echo "CLOSE:subGroupId={$subGroupId}<br />\n";
+ //* NOISY-DEBUG: */ echo "CLOSE:subGroupId={$subGroupId}<br />\n";
}
/**
if ((isset($this->groups[$idx])) && ($this->groups[$this->groups[$idx]]['opened'] === false)) {
// Then add it's content
$groupContent = trim($this->groups[$this->groups[$idx]]['content']);
- //* DEBUG: */ echo "group={$this->groups[$idx]},content=<pre>".htmlentities($groupContent)."</pre><br />\n";
+ //* NOISY-DEBUG: */ echo "group={$this->groups[$idx]},content=<pre>".htmlentities($groupContent)."</pre><br />\n";
$content .= $groupContent;
} elseif ((isset($this->subGroups[$idx])) && ($this->subGroups[$this->subGroups[$idx]]['opened'] === false)) {
// Then add it's content
$subGroupContent = $this->subGroups[$this->subGroups[$idx]]['content'];
- //* DEBUG: */ echo "subgroup={$this->subGroups[$idx]},content=<pre>".htmlentities($subGroupContent)."</pre><br />\n";
+ //* NOISY-DEBUG: */ echo "subgroup={$this->subGroups[$idx]},content=<pre>".htmlentities($subGroupContent)."</pre><br />\n";
$content .= trim($subGroupContent);
} else {
// Something went wrong
}
// Return it
- //* DEBUG: */ echo "content=<pre>".htmlentities($content)."</pre> (".strlen($content).")<br />\n";
+ //* NOISY-DEBUG: */ echo "content=<pre>".htmlentities($content)."</pre> (".strlen($content).")<br />\n";
return $content;
}
*
* @param $groupId Id of group to check
* @return $isOpened Whether the specified group is open
+ * @throws InvalidArgumentException If a parameter has an invalid value
*/
protected function ifGroupIsOpened (string $groupId) {
+ // Check on parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: groupId=%s - CALLED!', $groupId));
+ if (empty($groupId)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "groupId" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Is the group open?
$isOpened = ((isset($this->groups[$groupId])) && ($this->groups[$groupId]['opened'] === true));
// Return status
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: isOpened=%d - EXIT!', intval($isOpened)));
return $isOpened;
}
*
* @param $fieldName Name of the field we shall fetch
* @return $fieldValue Value from field
+ * @throws InvalidArgumentException If a parameter has an invalid value
* @throws NullPointerException Thrown if $valueInstance is null
*/
public function getValueField (string $fieldName) {
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: fieldName=%s - CALLED!', $fieldName));
+ if (empty($fieldName)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "fieldName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Init value
$fieldValue = NULL;
// The $valueInstance attribute should not be null!
if (is_null($this->getValueInstance())) {
// Throws an exception here
- throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
+ throw new NullPointerException($this, FrameworkInterface::EXCEPTION_IS_NULL_POINTER);
}
// Is the field set?
if ($this->getValueInstance()->isFieldSet($fieldName)) {
// Get the field value
$fieldValue = $this->getValueInstance()->getField($fieldName);
- //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput($fieldName.'[]='.gettype($fieldValue).'('.strlen($fieldValue).') - Value instance!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput($fieldName.'[]='.gettype($fieldValue).'('.strlen($fieldValue).') - Value instance!');
} elseif ((!is_null($this->extraInstance)) && ($this->extraInstance->isFieldSet($fieldName))) {
// So try the extra instance
$fieldValue = $this->extraInstance->getField($fieldName);
- //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput($fieldName.'[]='.gettype($fieldValue).'('.strlen($fieldValue).') - Extra instance!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput($fieldName.'[]='.gettype($fieldValue).'('.strlen($fieldValue).') - Extra instance!');
} else {
// Field is not set
$this->debugOutput('BASE-HELPER: fieldName=' . $fieldName . ' is not set! - @TODO');
}
// Return it
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: fieldValue[%s]=%s - EXIT!', gettype($fieldValue), $fieldValue));
return $fieldValue;
}
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
* @return $withRegistration Whether with registration date
*/
public function ifIncludeRegistrationStamp () {
- $withRegistration = (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('block_shows_registration') == 'Y');
+ $withRegistration = FrameworkBootstrap::getConfigurationInstance()->isEnabled('block_shows_registration');
return $withRegistration;
}
// Import framework stuff
use Org\Mxchange\CoreFramework\Helper\Template\HelpableTemplate;
+use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
/**
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
* @todo 0% done
*/
public function flushContent () {
- $this->partialStub("Please implement this method.");
+ DebugMiddleware::getSelfInstance()->partialStub("Please implement this method.");
}
}
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
use Org\Mxchange\CoreFramework\Generic\NullPointerException;
use Org\Mxchange\CoreFramework\Helper\Template\HelpableTemplate;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
+use Org\Mxchange\CoreFramework\Registry\Object\ObjectRegistry;
use Org\Mxchange\CoreFramework\Template\CompileableTemplate;
// Import SPL stuff
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
try {
// Get last executed pre filter
- $extraInstance = GenericRegistry::getRegistry()->getInstance('extra');
+ $extraInstance = ObjectRegistry::getRegistry('generic')->getInstance('extra');
} catch (NullPointerException $e) {
// Instance in registry is not set (NULL)
// @TODO We need to log this later
* @return $required Whether the email address is required
*/
public function ifRegisterRequiresEmailVerification () {
- $required = (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('register_requires_email') == 'Y');
+ $required = FrameworkBootstrap::getConfigurationInstance()->isEnabled('register_requires_email');
return $required;
}
* @return $required Whether profile data shall be asked
*/
public function ifRegisterIncludesProfile () {
- $required = (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('register_includes_profile') == 'Y');
+ $required = FrameworkBootstrap::getConfigurationInstance()->isEnabled('register_includes_profile');
return $required;
}
* @return $isSecured Whether this form is secured by a CAPTCHA
*/
public function ifFormSecuredWithCaptcha () {
- $isSecured = (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry($this->getFormName() . '_captcha_secured') == 'Y');
+ $isSecured = FrameworkBootstrap::getConfigurationInstance()->isEnabled($this->getFormName() . '_captcha_secured');
return $isSecured;
}
* @return $required Whether personal data shall be asked
*/
public function ifRegisterIncludesPersonaData () {
- $required = (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('register_personal_data') == 'Y');
+ $required = FrameworkBootstrap::getConfigurationInstance()->isEnabled('register_personal_data');
return $required;
}
* @return $required Whether birthday shall be asked
*/
public function ifProfileIncludesBirthDay () {
- $required = (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('profile_includes_birthday') == 'Y');
+ $required = FrameworkBootstrap::getConfigurationInstance()->isEnabled('profile_includes_birthday');
return $required;
}
* @return $isUnique
*/
public function ifEmailMustBeUnique () {
- $isUnique = (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('register_email_unique') == 'Y');
+ $isUnique = FrameworkBootstrap::getConfigurationInstance()->isEnabled('register_email_unique');
return $isUnique;
}
* @return $required Whether the specified chat protocol is enabled
*/
public function ifChatEnabled (string $chatProtocol) {
- $required = (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('chat_enabled_' . $chatProtocol) == 'Y');
+ $required = FrameworkBootstrap::getConfigurationInstance()->isEnabled('chat_protocol_' . $chatProtocol);
return $required;
}
* @return $isEnabled Whether the login is enabled or disabled
*/
public function ifLoginIsEnabled () {
- $isEnabled = (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('login_enabled') == 'Y');
+ $isEnabled = FrameworkBootstrap::getConfigurationInstance()->isEnabled('user_login');
return $isEnabled;
}
* @return $isEnabled Whether the login shall be done by username
*/
public function ifLoginWithUsername () {
- $isEnabled = (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('login_type') == "username");
+ $isEnabled = (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('login_type') == 'username');
return $isEnabled;
}
* @return $isEnabled Whether the login shall be done by email
*/
public function ifLoginWithEmail () {
- $isEnabled = (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('login_type') == "email");
+ $isEnabled = (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('login_type') == 'email');
return $isEnabled;
}
* @return $isAllowed Whether guest login is allowed
*/
public function ifGuestLoginAllowed () {
- $isAllowed = (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('guest_login_allowed') == 'Y');
+ $isAllowed = FrameworkBootstrap::getConfigurationInstance()->isEnabled('guest_login');
return $isAllowed;
}
* @return $requireConfirm Whether email change must be confirmed
*/
public function ifEmailChangeRequireConfirmation () {
- $requireConfirm = (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('email_change_confirmation') == 'Y');
+ $requireConfirm = FrameworkBootstrap::getConfigurationInstance()->isEnabled('email_change_confirmation');
return $requireConfirm;
}
* @return $emailChange Whether changing email address is allowed
*/
public function ifEmailChangeAllowed () {
- $emailChange = (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('email_change_allowed') == 'Y');
+ $emailChange = FrameworkBootstrap::getConfigurationInstance()->isEnabled('email_change');
return $emailChange;
}
* @return $refillActive Whether the refill page is active
*/
public function ifRefillPageActive () {
- $refillActive = (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('refill_page_active') == 'Y');
+ $refillActive = FrameworkBootstrap::getConfigurationInstance()->isEnabled('refill_page_active');
return $refillActive;
}
use Org\Mxchange\CoreFramework\Generic\NullPointerException;
use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
use Org\Mxchange\CoreFramework\Helper\Template\HelpableTemplate;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
use Org\Mxchange\CoreFramework\Utils\Strings\StringUtils;
use Org\Mxchange\CoreFramework\Template\CompileableTemplate;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Sanity-check on it
if (is_null($requestInstance)) {
// Throw an exception here
- throw new NullPointerException($helperInstance, self::EXCEPTION_IS_NULL_POINTER);
+ throw new NullPointerException($helperInstance, FrameworkInterface::EXCEPTION_IS_NULL_POINTER);
}
// Get page (this will throw an exception if not set)
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Import framework stuff
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
+use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
use Org\Mxchange\CoreFramework\Template\CompileableTemplate;
// Import SPL stuff
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
* @todo Rewrite this to SplFileInfo/Object
*/
public function finishImage () {
- $this->partialStub('Unfinished method.');
+ DebugMiddleware::getSelfInstance()->partialStub('Unfinished method.');
return;
// Call parent method
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
namespace Org\Mxchange\CoreFramework\Index;
// Import framework stuff
-use Org\Mxchange\CoreFramework\EntryPoint\ApplicationEntryPoint;
use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
use Org\Mxchange\CoreFramework\Filesystem\File\BaseBinaryFile;
use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
// Import SPL stuff
use \SplFileInfo;
-use \UnexpectedValueException;
/**
* A general index class
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
use Org\Mxchange\CoreFramework\Filesystem\File\BaseBinaryFile;
use Org\Mxchange\CoreFramework\Filesystem\File\BinaryFile;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Index\BaseIndex;
use Org\Mxchange\CoreFramework\Index\Indexable;
use Org\Mxchange\CoreFramework\Utils\Arrays\ArrayUtils;
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
strlen($data),
$data,
$this->getIteratorInstance()->getBinaryFileInstance()->getHeaderSize()
- ));
+ ), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
} elseif (empty(trim($data, chr(0)))) {
// Empty file header
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-INDEX: File header is empty - EXIT!');
throw new UnexpectedValueException(sprintf('data=%s does not end with "%s"',
$data,
chr(BinaryFile::SEPARATOR_HEADER_ENTRIES)
- ));
+ ), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
}
// Okay, then remove it
$data = substr($data, 0, -1);
// And update seek position
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-INDEX: Calling this->iteratorInstance->binaryFileInstance->updateSeekPosition() ...');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-INDEX: Invoking this->iteratorInstance->binaryFileInstance->updateSeekPosition() ...');
$this->getIteratorInstance()->getBinaryFileInstance()->updateSeekPosition();
/*
$header = explode(chr(BinaryFile::SEPARATOR_HEADER_DATA), $data);
// Map numeric entries to associative (alpha-numeric) elements
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-INDEX: Calling ArrayUtils::mapNumericKeysToAssociative(%d) ...', count($header)));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-INDEX: Invoking ArrayUtils::mapNumericKeysToAssociative(%d) ...', count($header)));
//* PRINTR-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-INDEX: header(%d)=%s', count($header), print_r($header, true)));
$header = ArrayUtils::mapNumericKeysToAssociative($header, [
BinaryFile::HEADER_NAME_MAGIC,
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-INDEX: HEADER_INDEX_ELEMENT_COUNT=%d,header()=%d', BinaryFile::HEADER_INDEX_ELEMENT_COUNT, count($header)));
if (count($header) != BinaryFile::HEADER_INDEX_ELEMENT_COUNT) {
// Bad header
- throw new UnexpectedValueException(sprintf('header()=%d is not expected value %d', count($header), BinaryFile::HEADER_INDEX_ELEMENT_COUNT));
+ throw new UnexpectedValueException(sprintf('header()=%d is not expected value %d', count($header), BinaryFile::HEADER_INDEX_ELEMENT_COUNT), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
} elseif ($header[BinaryFile::HEADER_NAME_MAGIC] !== Indexable::INDEX_MAGIC) {
// Magic must be in first element
- throw new UnexpectedValueException(sprintf('header[%s]=%s is not the expected magic (%s)', BinaryFile::HEADER_NAME_MAGIC, $header[BinaryFile::HEADER_NAME_MAGIC], Indexable::INDEX_MAGIC));
+ throw new UnexpectedValueException(sprintf('header[%s]=%s is not the expected magic (%s)', BinaryFile::HEADER_NAME_MAGIC, $header[BinaryFile::HEADER_NAME_MAGIC], Indexable::INDEX_MAGIC), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
} elseif (strlen($header[BinaryFile::HEADER_NAME_TOTAL_ENTRIES]) != BinaryFile::LENGTH_COUNT) {
// Length of total entries not matching
- throw new UnexpectedValueException(sprintf('header[%s](%d)=%s does not have expected length %d', BinaryFile::HEADER_NAME_TOTAL_ENTRIES, strlen($header[BinaryFile::HEADER_NAME_TOTAL_ENTRIES]), $header[BinaryFile::HEADER_NAME_TOTAL_ENTRIES], BinaryFile::LENGTH_COUNT));
+ throw new UnexpectedValueException(sprintf('header[%s](%d)=%s does not have expected length %d', BinaryFile::HEADER_NAME_TOTAL_ENTRIES, strlen($header[BinaryFile::HEADER_NAME_TOTAL_ENTRIES]), $header[BinaryFile::HEADER_NAME_TOTAL_ENTRIES], BinaryFile::LENGTH_COUNT), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
}
// Decode count
);
// Write it to disk (header is always at seek position 0)
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-INDEX: Calling this->iteratorInstance->binaryFileInstance->writeAtPosition(0, header=%s) ...', $header));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-INDEX: Invoking this->iteratorInstance->binaryFileInstance->writeAtPosition(0, header=%s) ...', $header));
$this->getIteratorInstance()->getBinaryFileInstance()->writeAtPosition(0, $header);
// Trace message
$this->getIteratorInstance()->getBinaryFileInstance()->setHeaderSize($headerSize);
// Init counters and gaps array
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-INDEX: Calling this->iteratorInstance->binaryFileInstance->initCountersGapsArray() ...');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-INDEX: Invoking this->iteratorInstance->binaryFileInstance->initCountersGapsArray() ...');
$this->getIteratorInstance()->getBinaryFileInstance()->initCountersGapsArray();
// Default is not created
// Is the file's header initialized?
if (!$this->getIteratorInstance()->getBinaryFileInstance()->isFileHeaderInitialized()) {
// First pre-allocate a bit
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-INDEX: Calling this->iteratorInstance->binaryFileInstance->preAllocateFile(index) ...');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-INDEX: Invoking this->iteratorInstance->binaryFileInstance->preAllocateFile(index) ...');
$this->getIteratorInstance()->getBinaryFileInstance()->preAllocateFile('index');
// Then write file header
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-INDEX: Calling this->iteratorInstance->binaryFileInstance->createFileHeader() ...');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-INDEX: Invoking this->iteratorInstance->binaryFileInstance->createFileHeader() ...');
$this->getIteratorInstance()->getBinaryFileInstance()->createFileHeader();
// Mark as freshly created
}
// Load the file header
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-INDEX: Calling this->readIndexHeader() ...');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-INDEX: Invoking this->readIndexHeader() ...');
$this->readIndexHeader();
// Freshly created?
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-INDEX: created=%d', intval($created)));
if (!$created) {
// Analyze file structure
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-INDEX: Calling this->iteratorInstance->binaryFileInstance->analyzeFileStructure() ...');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-INDEX: Invoking this->iteratorInstance->binaryFileInstance->analyzeFileStructure() ...');
$this->getIteratorInstance()->getBinaryFileInstance()->analyzeFileStructure();
}
throw new OutOfBoundsException(sprintf('seekPosition=%d is not valid.', $seekPosition));
} elseif (empty($dataStream)) {
// Empty dataStream
- throw new InvalidArgumentException('Parameter "dataStream" is empty');
+ throw new InvalidArgumentException('Parameter "dataStream" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
}
// Call iterated object's method
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-INDEX: Calling this->iteratorInstance->binaryFileInstance->writeAtPosition(%d, %s) ...', $seekPosition, $dataStream));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-INDEX: Invoking this->iteratorInstance->binaryFileInstance->writeAtPosition(%d, %s) ...', $seekPosition, $dataStream));
$status = $this->getIteratorInstance()->getBinaryFileInstance()->writeAtPosition($seekPosition, $dataStream);
// Return status
namespace Org\Mxchange\CoreFramework\Index\File\Stack;
// Import framework stuff
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Index\File\BaseFileIndex;
use Org\Mxchange\CoreFramework\Index\File\Stack\IndexableStack;
use Org\Mxchange\CoreFramework\Index\Indexable;
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-STACK-INDEX: stackName=%s,data()=%d - CALLED!', $stackName, count($data)));
if (empty($stackName)) {
// Throw IAE
- throw new InvalidArgumentException('Parameter "stackName" is empty');
+ throw new InvalidArgumentException('Parameter "stackName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif (count($data) == 0) {
// Throw it again
throw new InvalidArgumentException('Parameter "data" is an empty array');
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-STACK-INDEX: stackName=%s,hash{}=0x%s,rawData(%d)=%s', $stackName, bin2hex($data[StackableFile::ARRAY_NAME_HASH]), strlen($rawData), $rawData));
// Search for next free gap
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-STACK-INDEX: Calling this->iteratorInstance->binaryFileInstance->searchNextGap(%d) ...', strlen($rawData)));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-STACK-INDEX: Invoking this->iteratorInstance->binaryFileInstance->searchNextGap(%d) ...', strlen($rawData)));
$gapPosition = $this->getIteratorInstance()->getBinaryFileInstance()->searchNextGap(strlen($rawData));
// Gap position cannot be smaller or equal than header length
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-STACK-INDEX: stackName=%s,hash{}=0x%s,gapPosition=%s', $stackName, bin2hex($data[StackableFile::ARRAY_NAME_HASH]), $gapPosition));
if ($gapPosition <= ($this->getIteratorInstance()->getBinaryFileInstance()->getHeaderSize() + 1)) {
// Not valid gap position returned
- throw new UnexpectedValueException(sprintf('gapPosition[%s]=%d is smaller or equal headerSize+1=%d', gettype($gapPosition), $gapPosition, ($this->getIteratorInstance()->getBinaryFileInstance()->getHeaderSize() + 1)));
+ throw new UnexpectedValueException(sprintf('gapPosition[%s]=%d is smaller or equal headerSize+1=%d', gettype($gapPosition), $gapPosition, ($this->getIteratorInstance()->getBinaryFileInstance()->getHeaderSize() + 1)), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
}
// Then write the data at that gap
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-STACK-INDEX: Calling this->iteratorInstance->binaryFileInstance->writeData(%d,%s) ...', $gapPosition, $rawData));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-STACK-INDEX: Invoking this->iteratorInstance->binaryFileInstance->writeData(%d,%s) ...', $gapPosition, $rawData));
$this->getIteratorInstance()->getBinaryFileInstance()->writeData($gapPosition, $rawData);
// Trace message
// Import framework stuff
use Org\Mxchange\CoreFramework\Iterator\BaseIterator;
+use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
// Import SPL stuff
use \Iterator;
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
// Default is null
$current = null;
- $this->partialStub('Please implement this method.');
+ DebugMiddleware::getSelfInstance()->partialStub('Please implement this method.');
// Return it
return $current;
// Default is null
$key = null;
- $this->partialStub('Please implement this method.');
+ DebugMiddleware::getSelfInstance()->partialStub('Please implement this method.');
// Return it
return $key;
* @return void
*/
public function next () {
- $this->partialStub('Please implement this method.');
+ DebugMiddleware::getSelfInstance()->partialStub('Please implement this method.');
}
/**
* @return void
*/
public function rewind () {
- $this->partialStub('Please implement this method.');
+ DebugMiddleware::getSelfInstance()->partialStub('Please implement this method.');
}
/**
* @return void
*/
public function valid () {
- $this->partialStub('Please implement this method.');
+ DebugMiddleware::getSelfInstance()->partialStub('Please implement this method.');
}
}
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Import framework stuff
use Org\Mxchange\CoreFramework\Filesystem\File\BinaryFile;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Iterator\BaseIterator;
use Org\Mxchange\CoreFramework\Traits\File\BinaryFileTrait;
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: CALLED!');
if (!$this->valid()) {
// Throw BMCE
- throw new BadMethodCallException('Current key cannot be valid, forgot to invoke valid()?');
+ throw new BadMethodCallException('Current key cannot be valid, forgot to invoke valid()?', FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
}
// Call file instance
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: CALLED!');
if (!$this->valid()) {
// Throw BMCE
- throw new BadMethodCallException('Current key cannot be valid, forgot to invoke valid()?');
+ throw new BadMethodCallException('Current key cannot be valid, forgot to invoke valid()?', FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
}
// Get key from file instance
use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Generic\NullPointerException;
use Org\Mxchange\CoreFramework\Iterator\BaseIterator;
+use Org\Mxchange\CoreFramework\Registry\Object\ObjectRegistry;
use Org\Mxchange\CoreFramework\Registry\Register;
use Org\Mxchange\CoreFramework\Registry\Registerable;
-use Org\Mxchange\CoreFramework\Registry\Sub\SubRegistry;
use Org\Mxchange\CoreFramework\Traits\Registry\RegisterTrait;
// Import SPL stuff
use \BadMethodCallException;
use \LogicException;
+use \UnexpectedValueException;
/**
* A registry iterator
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
*/
public final static function createRegistryIterator (Register $registryInstance) {
// Get new instance
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('REGISTRY-ITERATOR: registryInstance=%s - CALLED!', $registryInstance->__toString()));
$iteratorInstance = new RegistryIterator();
// Set registry here
$iteratorInstance->setRegistryInstance($registryInstance);
// Return the prepared instance
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('REGISTRY-ITERATOR: iteratorInstance=%s - EXIT!', $iteratorInstance->__toString()));
return $iteratorInstance;
}
*/
public function initIterator (array $onlyRegistries = []) {
// Set it in this registry
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('REGISTRY-ITERATOR: onlyRegistries()=%d - CALLED!', count($onlyRegistries)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('REGISTRY-ITERATOR: onlyRegistries()=%d - CALLED!', count($onlyRegistries)));
$this->setOnlyRegistries($onlyRegistries);
// Get generic registry entries from it
$entries = $this->getRegistryInstance()->getGenericRegistry();
// Anything in there?
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('REGISTRY-ITERATOR[generic]: entries()=%d', count($entries)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('REGISTRY-ITERATOR: entries()=%d', count($entries)));
if (count($entries) > 0) {
// Debugging:
/* DEBUG-DIE: */ ApplicationEntryPoint::exitApplication(sprintf('[%s:%d]: UNFINISHED: entries=%s', __METHOD__, __LINE__, print_r($entries, TRUE)));
$entries = $this->getRegistryInstance()->getInstanceRegistry();
// Anything in there?
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('REGISTRY-ITERATOR[instance]: entries()=%d', count($entries)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('REGISTRY-ITERATOR: entries()=%d', count($entries)));
if (count($entries) > 0) {
// Then run over all
foreach ($entries as $key => $entry) {
// Is an unwanted registry found?
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('REGISTRY-ITERATOR[instance]: key=%s,entry[]=%s', $key, gettype($entry)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('REGISTRY-ITERATOR: key=%s,entry[%s]=%s', $key, gettype($entry), $entry->__toString()));
if (substr($key, -8, 8) == 'registry') {
// Skip this!
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('REGISTRY-ITERATOR[instance]: key=%s is a registry key, skipping ...', $key));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('REGISTRY-ITERATOR: key=%s is a registry key, skipping ...', $key));
continue;
}
// Is it an instance of a sub-registry?
if (count($onlyRegistries) > 0 && !in_array($key, $onlyRegistries, TRUE)) {
// Not in requested registries
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('REGISTRY-ITERATOR[instance]: key=%s is not wanted, skipping ...', $key));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('REGISTRY-ITERATOR: key=%s is not wanted, skipping ...', $key));
continue;
- } elseif ($entry instanceof SubRegistry) {
+ } elseif ($entry instanceof ObjectRegistry) {
// Get iterator from this instance
- $subRegistryInstances = $entry->getInstanceRegistry();
+ $objectRegistryInstances = $entry->getInstanceRegistry();
// Add all sub-registry keys to this registry keys array
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('REGISTRY-ITERATOR[instance]: subRegistryInstances()=%d', count($subRegistryInstances)));
- //* DEBUG-DIE: */ ApplicationEntryPoint::exitApplication(sprintf('[%s:%d]: key=%s,subRegistryInstances=%s', __METHOD__, __LINE__, $key, print_r($subRegistryInstances, TRUE)));
- foreach (array_keys($subRegistryInstances) as $subKey) {
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('REGISTRY-ITERATOR: objectRegistryInstances()=%d', count($objectRegistryInstances)));
+ //* DEBUG-DIE: */ ApplicationEntryPoint::exitApplication(sprintf('[%s:%d]: key=%s,objectRegistryInstances=%s', __METHOD__, __LINE__, $key, print_r($objectRegistryInstances, TRUE)));
+ foreach (array_keys($objectRegistryInstances) as $subKey) {
// Add it
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('REGISTRY-ITERATOR[instance]: Adding key=%s,subKey=%s ...', $key, $subKey));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('REGISTRY-ITERATOR: Adding key=%s,subKey=%s ...', $key, $subKey));
array_push($this->registryKeys['instance'], $subKey);
// Is the current key set?
if (is_null($this->key)) {
// Init key
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('REGISTRY-ITERATOR[instance]: Setting subKey=%s as first key ...', $subKey));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('REGISTRY-ITERATOR: Setting this->key=%s as first key (subKey) ...', $subKey));
$this->key = $subKey;
}
}
continue;
} elseif (!($entry instanceof Registerable)) {
// Not registerable?!
- throw new LogicException(sprintf('entry[]=%s does not implement Registerable.', gettype($entry)));
+ throw new LogicException(sprintf('entry[]=%s does not implement Registerable.', gettype($entry)), FrameworkInterface::EXCEPTION_LOGIC_EXCEPTION);
}
// Is the current key set?
if (is_null($this->key)) {
// Init key
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('REGISTRY-ITERATOR[instance]: Setting key=%s as first key ...', $key));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('REGISTRY-ITERATOR: Setting this->key=%s as first key (key) ...', $key));
$this->key = $key;
}
// Add key to array
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('REGISTRY-ITERATOR[instance]: key=%s - Adding ...', $key));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('REGISTRY-ITERATOR: key=%s - Adding ...', $key));
//* DEBUG-DIE: */ ApplicationEntryPoint::exitApplication(sprintf('[%s:%d]: key=%s,entry=%s', __METHOD__, __LINE__, $key, print_r($entry, TRUE)));
array_push($this->registryKeys['instance'], $key);
}
}
// Trace message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('REGISTRY-ITERATOR: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('REGISTRY-ITERATOR: EXIT!');
}
/**
*/
public function current () {
// Default is null
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('REGISTRY-ITERATOR[%s]: CALLED!', $this->key()));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('REGISTRY-ITERATOR[%s]: CALLED!', $this->key()));
//* DEBUG-DIE: */ ApplicationEntryPoint::exitApplication(sprintf('[%s:%d]: this->key(%d)[%s]=%s,this->valid=%d,this->registryKeys=%s', __METHOD__, __LINE__, strlen($this->key()), gettype($this->key()), $this->key(), intval($this->valid()), print_r($this->registryKeys, TRUE)));
$current = NULL;
$entries = [];
$allRegistries = $this->getRegistryInstance()->getInstanceRegistry();
// Loop through all sub-sets
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('REGISTRY-ITERATOR[%s]: allRegistries()=%d', $this->key(), count($allRegistries)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('REGISTRY-ITERATOR[%s]: allRegistries()=%d', $this->key(), count($allRegistries)));
foreach ($allRegistries as $registryKey => $registryInstance) {
// Is this key wanted?
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('REGISTRY-ITERATOR[%s]: registryKey=%s', $this->key(), $registryKey));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('REGISTRY-ITERATOR[%s]: registryKey=%s', $this->key(), $registryKey));
if (count($this->onlyRegistries) == 0 || in_array($registryKey, $this->onlyRegistries)) {
// Yes, then loop through them only
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('REGISTRY-ITERATOR[%s]: registryKey=%s,this->onlyRegistries()=%d', $this->key(), $registryKey, count($this->onlyRegistries)));
$instances = $registryInstance->getInstanceRegistry();
// The key should be there
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('REGISTRY-ITERATOR[%s]: Handling registryKey=%s ...', $this->key(), $registryKey));
- //* DEBUG-DIE: */ ApplicationEntryPoint::exitApplication(sprintf('[%s:%d]: instances=%s', __METHOD__, __LINE__, print_r($instances, TRUE)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('REGISTRY-ITERATOR[%s]: Handling instances()=%d,registryKey=%s ...', $this->key(), count($instances), $registryKey));
if (!isset($instances[$this->key()])) {
- // Skip below code
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('REGISTRY-ITERATOR[%s]: registryKey=%s has no this->key=%s, skipping ...', $this->key(), $registryKey));
+ // Not found
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->warningMessage(sprintf('REGISTRY-ITERATOR[%s]: registryKey=%s has no this->key=%s - CONTINUE!', $this->key(), $registryKey, $this->key()));
continue;
}
- // Set as current element and leave loop
+ // Set as current
$current = $instances[$this->key()];
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('REGISTRY-ITERATOR[%s]: registryKey=%s,current=%s found. - BREAK!', $this->key(), $registryKey, $current->__toString()));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('REGISTRY-ITERATOR[%s]: current=%s', $this->key(), $current->__toString()));
break;
}
}
// Is current still NULL?
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('REGISTRY-ITERATOR[%s]: registryKey=%s,current[]=%s', $this->key(), $registryKey, gettype($current)));
if (is_null($current)) {
// This cannot happen and indicates a logic error
- throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
+ throw new NullPointerException($this, FrameworkInterface::EXCEPTION_IS_NULL_POINTER);
}
// Return it
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('REGISTRY-ITERATOR[%s]: current[%s]=%s - EXIT!', $this->key(), gettype($current), $current));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('REGISTRY-ITERATOR[%s]: current[%s]=%s - EXIT!', $this->key(), gettype($current), $current));
return $current;
}
*/
public function key () {
// Return it
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('REGISTRY-ITERATOR[%s]: EXIT!', $this->key));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('REGISTRY-ITERATOR: this->key=%s EXIT!', $this->key));
return $this->key;
}
*/
public function next () {
// Is valid() still TRUE?
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('REGISTRY-ITERATOR[%s]: CALLED!', $this->key()));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('REGISTRY-ITERATOR[%s]: CALLED!', $this->key()));
//* DEBUG-DIE: */ ApplicationEntryPoint::exitApplication(sprintf('[%s:%d]: this->key(%d)[%s]=%s,this->valid=%d,this->registryKeys=%s', __METHOD__, __LINE__, strlen($this->key()), gettype($this->key()), $this->key(), intval($this->valid()), print_r($this->registryKeys, TRUE)));
if (!$this->valid()) {
// Bad method call!
- throw new BadMethodCallException(sprintf('this->key[%s]=%s is no longer valid, but method was called.', gettype($this->key()), $this->key()));
+ throw new BadMethodCallException(sprintf('this->key[%s]=%s is no longer valid, but method was called.', gettype($this->key()), $this->key()), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
} elseif ((count($this->registryKeys['generic']) == 0) && (count($this->registryKeys['instance']) == 0)) {
// Both arrays are empty
- throw new BadMethodCallException('No array elements in "generic" and "instance" found but method called.');
+ throw new BadMethodCallException('No array elements in "generic" and "instance" found but method called.', FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
}
// Default is not valid
$registryType = 'invalid';
// Get first array element ...
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('REGISTRY-ITERATOR[%s]: this->registryKeys[generic]()=%d,this->registryKeys[instance]()=%d', $this->key(), count($this->registryKeys['generic']), count($this->registryKeys['instance'])));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('REGISTRY-ITERATOR[%s]: this->registryKeys[generic]()=%d,this->registryKeys[instance]()=%d', $this->key(), count($this->registryKeys['generic']), count($this->registryKeys['instance'])));
if (count($this->registryKeys['generic']) > 0) {
// First generic array
/* UNFINISHED */ ApplicationEntryPoint::exitApplication(sprintf('[%s:%d]: this->key(%d)[%s]=%s,this->valid=%d,this->registryKeys=%s', __METHOD__, __LINE__, strlen($this->key()), gettype($this->key()), $this->key(), intval($this->valid()), print_r($this->registryKeys, TRUE)));
}
// Is it still valid?
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('REGISTRY-ITERATOR[%s]: isNextValid=%d', $this->key(), intval($isNextValid)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('REGISTRY-ITERATOR[%s]: isNextValid=%d', $this->key(), intval($isNextValid)));
if (!$isNextValid) {
// Throw exception
- throw new BadMethodCallException(sprintf('this->key=%s is last key in this iteration. Forgot to invoke valid() before?', $this->key()));
+ throw new BadMethodCallException(sprintf('this->key=%s is last key in this iteration. Forgot to invoke valid() before?', $this->key()), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
} elseif ($registryType == 'invalid') {
// Not changed!
- throw new UnexpectedValueException('registryType has not been changed.');
+ throw new UnexpectedValueException('registryType has not been changed.', FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
}
// Yes, then advance to that entry
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('REGISTRY-ITERATOR: Setting this->key from this->registryKeys[%s][%d] ...', $registryType, $nextIndex));
$this->key = $this->registryKeys[$registryType][$nextIndex];
// Trace message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('REGISTRY-ITERATOR[%s]: EXIT!', $this->key()));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('REGISTRY-ITERATOR[%s]: EXIT!', $this->key()));
}
/**
*/
public function rewind () {
// Is current key first key?
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('REGISTRY-ITERATOR[%s]: CALLED!', $this->key()));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('REGISTRY-ITERATOR[%s]: CALLED!', $this->key()));
//* DEBUG-DIE: */ ApplicationEntryPoint::exitApplication(sprintf('[%s:%d]: this->key(%d)[%s]=%s,this->valid=%d,this->registryKeys=%s', __METHOD__, __LINE__, strlen($this->key()), gettype($this->key()), $this->key(), intval($this->valid()), print_r($this->registryKeys, TRUE)));
if (array_search($this->key(), $this->getRegistryKeys()) === 0) {
// rewind() cannot rewind first entry!
- throw new BadMethodCallException(sprintf('this->key=%s is already first element, but method was called.', $this->key()));
+ throw new BadMethodCallException(sprintf('this->key=%s is already first element, but method was called.', $this->key()), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
} elseif ((count($this->registryKeys['generic']) == 0) && (count($this->registryKeys['instance']) == 0)) {
// Both arrays are empty
- throw new BadMethodCallException('No array elements in "generic" and "instance" found but method called.');
+ throw new BadMethodCallException('No array elements in "generic" and "instance" found but method called.', FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
}
// Get first array element ...
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('REGISTRY-ITERATOR[%s]: this->registryKeys[generic]()=%d,this->registryKeys[instance]()=%d', $this->key(), count($this->registryKeys['generic']), count($this->registryKeys['instance'])));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('REGISTRY-ITERATOR[%s]: this->registryKeys[generic]()=%d,this->registryKeys[instance]()=%d', $this->key(), count($this->registryKeys['generic']), count($this->registryKeys['instance'])));
if (count($this->registryKeys['generic']) > 0) {
// First generic array
/* UNFINISHED */ ApplicationEntryPoint::exitApplication(sprintf('[%s:%d]: this->key(%d)[%s]=%s,this->valid=%d,this->registryKeys=%s', __METHOD__, __LINE__, strlen($this->key()), gettype($this->key()), $this->key(), intval($this->valid()), print_r($this->registryKeys, TRUE)));
} elseif (count($this->registryKeys['instance']) > 0) {
// Second instance
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('REGISTRY-ITERATOR: Setting this->key from this->registryKeys[instance][0] ...');
$this->key = $this->registryKeys['instance'][0];
}
// Trace message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('REGISTRY-ITERATOR[%s]: EXIT!', $this->key()));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('REGISTRY-ITERATOR[%s]: EXIT!', $this->key()));
}
/**
*/
public function valid () {
// Is the element there?
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('REGISTRY-ITERATOR[%s]: CALLED!', $this->key()));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('REGISTRY-ITERATOR[%s]: CALLED!', $this->key()));
//* DEBUG-DIE: */ ApplicationEntryPoint::exitApplication(sprintf('[%s:%d]: this->key(%d)[%s]=%s,this->registryKeys=%s', __METHOD__, __LINE__, strlen($this->key()), gettype($this->key()), $this->key(), print_r($this->registryKeys, TRUE)));
$valid = (in_array($this->key(), $this->registryKeys['instance']) || in_array($this->key(), $this->registryKeys['generic']));
// Return flag
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('REGISTRY-ITERATOR[%s]: valid=%d - EXIT!', $this->key(), intval($valid)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('REGISTRY-ITERATOR[%s]: valid=%d - EXIT!', $this->key(), intval($valid)));
return $valid;
}
// Import framework stuff
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Localization\ManageableLanguage;
use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
use Org\Mxchange\CoreFramework\ObjectArray\FrameworkArrayObject;
use Org\Mxchange\CoreFramework\Registry\Registerable;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
// Import SPL stuff
use \InvalidArgumentException;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Is the base path valid?
if (empty($languageBasePath)) {
// Language path is empty
- throw new InvalidArgumentException('languageBasePath is still empty');
+ throw new InvalidArgumentException('languageBasePath is still empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif (!is_dir($languageBasePath)) {
// Is not a path
throw new InvalidArgumentException(sprintf('languageBasePath=%s not found', $languageBasePath), self::EXCEPTION_INVALID_PATH_NAME);
<?php
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
+
/**
* A ??? list
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
* @todo 0% done
*/
public function getListIterator () {
- $this->partialStub('Please implement this method.');
+ DebugMiddleware::getSelfInstance()->partialStub('Please implement this method.');
}
/**
* @todo 0% done
*/
public function clearList () {
- $this->partialStub('Please implement this method.');
+ DebugMiddleware::getSelfInstance()->partialStub('Please implement this method.');
}
}
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-LIST: groupName=%s - CALLED!', $groupName));
if (empty($groupName)) {
// Throw IAE
- throw new InvalidArgumentException('Parameter "groupName" is empty');
+ throw new InvalidArgumentException('Parameter "groupName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
}
// Check on existence ...
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-LIST: groupName=%s - CALLED!', $groupName));
if (empty($groupName)) {
// Throw IAE
- throw new InvalidArgumentException('Parameter "groupName" is empty');
+ throw new InvalidArgumentException('Parameter "groupName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif ($this->isGroupSet($groupName)) {
// Throw the exception here
throw new BadMethodCallException(sprintf('groupName=%s is already set', $groupName), self::EXCEPTION_GROUP_ALREADY_ADDED);
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: groupName=' . $groupName . ',subGroup=' . $subGroup . ',visitableInstance=' . $visitableInstance->__toString() . ' - CALLED!');
if (empty($groupName)) {
// Throw IAE
- throw new InvalidArgumentException('Parameter "groupName" is empty');
+ throw new InvalidArgumentException('Parameter "groupName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif (empty($subGroup)) {
// Throw it again
- throw new InvalidArgumentException('Parameter "subGroup" is empty');
+ throw new InvalidArgumentException('Parameter "subGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif (!$this->isGroupSet($groupName)) {
// Throw the exception here
throw new BadMethodCallException(sprintf('groupName=%s is not a valid group', $groupName), self::EXCEPTION_GROUP_NOT_FOUND);
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: groupName[' . gettype($groupName) . ']=' . $groupName . ' - CALLED!');
if (empty($groupName)) {
// Throw IAE
- throw new InvalidArgumentException('Parameter "groupName" is empty');
+ throw new InvalidArgumentException('Parameter "groupName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif (!$this->isGroupSet($groupName)) {
// Throw the exception here
throw new BadMethodCallException(sprintf('groupName=%s is not a valid group', $groupName), self::EXCEPTION_GROUP_NOT_FOUND);
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: groupName=' . $groupName . ' - CALLED!');
if (empty($groupName)) {
// Throw IAE
- throw new InvalidArgumentException('Parameter "groupName" is empty');
+ throw new InvalidArgumentException('Parameter "groupName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif (!$this->isGroupSet($groupName)) {
// Throw the exception here
throw new BadMethodCallException(sprintf('groupName=%s is not a valid group', $groupName), self::EXCEPTION_GROUP_NOT_FOUND);
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: groupName=' . $groupName . ' - CALLED!');
if (empty($groupName)) {
// Throw IAE
- throw new InvalidArgumentException('Parameter "groupName" is empty');
+ throw new InvalidArgumentException('Parameter "groupName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif (!$this->isGroupSet($groupName)) {
// Throw the exception here
throw new BadMethodCallException(sprintf('groupName=%s is not a valid group', $groupName), self::EXCEPTION_GROUP_NOT_FOUND);
// Does this group exist?
if (empty($groupName)) {
// Throw IAE
- throw new InvalidArgumentException('Parameter "groupName" is empty');
+ throw new InvalidArgumentException('Parameter "groupName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif (!$this->isGroupSet($groupName)) {
// Throw the exception here
throw new BadMethodCallException(sprintf('groupName=%s is not a valid group', $groupName), self::EXCEPTION_GROUP_NOT_FOUND);
// Validate parameter
if (empty($hash)) {
// Throw IAE
- throw new InvalidArgumentException('Parameter "hash" is empty');
+ throw new InvalidArgumentException('Parameter "hash" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif (!isset($this->cache['is_valid'][$hash])) {
// Check it
$this->cache['is_valid'][$hash] = ((in_array($hash, $this->listIndex)) && (isset($this->listEntries[$hash])));
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-LIST: groupName=%s - CALLED!', $groupName));
if (empty($groupName)) {
// Throw IAE
- throw new InvalidArgumentException('Parameter "groupName" is empty');
+ throw new InvalidArgumentException('Parameter "groupName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif (!$this->isGroupSet($groupName)) {
// Throw the exception here
throw new BadMethodCallException(sprintf('groupName=%s is not a valid group', $groupName), self::EXCEPTION_GROUP_NOT_FOUND);
// Is the hash valid?
if (empty($hash)) {
// Throw IAE
- throw new InvalidArgumentException('Parameter "hash" is empty');
+ throw new InvalidArgumentException('Parameter "hash" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif (!$this->isHashValid($hash)) {
// Throw an exception here, hashIndex is unknown at this point
throw new InvalidListHashException(array($this, $hash, -999), self::EXCEPTION_INVALID_HASH);
// Import framework stuff
use Org\Mxchange\CoreFramework\Lists\BaseList;
use Org\Mxchange\CoreFramework\Lists\Listable;
+use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
/**
* A ListGroup list
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
* @todo 0% done
*/
public function clearList () {
- $this->partialStub('Please implement this method.');
+ DebugMiddleware::getSelfInstance()->partialStub('Please implement this method.');
}
}
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Import framwork stuff
use Org\Mxchange\CoreFramework\Mailer\BaseMailer;
use Org\Mxchange\CoreFramework\Mailer\DeliverableMail;
+use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
/**
* A ??? mailer class
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
* @todo 0% done
*/
public function deliverEmail() {
- $this->partialStub("You have to implement this method.");
+ DebugMiddleware::getSelfInstance()->partialStub("You have to implement this method.");
}
/**
* @todo 0% done
*/
public function sendAdminNotification() {
- $this->partialStub("You have to implement this method.");
+ DebugMiddleware::getSelfInstance()->partialStub("You have to implement this method.");
}
}
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// The recipient should be a user instance, right?
if (!$recipientInstance instanceof ManageableMember) {
// Invalid entry found!
- throw new UnexpectedValueException(sprintf('recipientInstance[]=%s does not implement ManageableMember', gettype($recipientInstance)));
+ throw new UnexpectedValueException(sprintf('recipientInstance[]=%s does not implement ManageableMember', gettype($recipientInstance)), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
}
// User class found, so entry is valid, first load the template
// Is the value instance there?
if (!isset($recipientList['values'][$variable])) {
// Throw exception
- throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
+ throw new NullPointerException($this, FrameworkInterface::EXCEPTION_IS_NULL_POINTER);
}
// Get the field from the value instance
use Org\Mxchange\CoreFramework\Filesystem\FileNotFoundException;
use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
+use Org\Mxchange\CoreFramework\Template\CompileableTemplate;
use Org\Mxchange\CoreFramework\Traits\Template\CompileableTemplateTrait;
/**
// Import framework stuff
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
+use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
/**
* A ??? output class
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
* @todo 0% done
*/
public final function output ($outStream = false, $stripTags = false) {
- $this->partialStub('Please implement this method. outStream()=' . strlen($outStream) . ',stripTags=' . intval($stripTags));
+ DebugMiddleware::getSelfInstance()->partialStub('Please implement this method. outStream()=' . strlen($outStream) . ',stripTags=' . intval($stripTags));
}
/**
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Import framework stuff
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
use Org\Mxchange\CoreFramework\Debug\Debugger;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
use Org\Mxchange\CoreFramework\Output\Debug\BaseDebugOutput;
use Org\Mxchange\CoreFramework\Registry\Registerable;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
/**
* Cached configuration entry 'debug_*_output_timings'
*/
- private $debugOutputTimings = 'N';
+ private $isDebugOutputTimingsEnabled = FALSE;
/**
* Protected constructor
parent::__construct(__CLASS__);
// Cache configuration entry
- $this->debugOutputTimings = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('debug_' . FrameworkBootstrap::getRequestTypeFromSystem() . '_output_timings');
+ $this->isDebugOutputTimingsEnabled = FrameworkBootstrap::getConfigurationInstance()->isEnabled('debug_' . FrameworkBootstrap::getRequestTypeFromSystem() . '_output_timings');
}
/**
}
// Are debug times enabled?
- if ($this->debugOutputTimings == 'Y') {
+ if ($this->isDebugOutputTimingsEnabled) {
// Output it first
$output = $this->getPrintableExecutionTime() . $output;
}
*/
public function streamData (string $data) {
self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.');
- throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
}
// Import framework stuff
use Org\Mxchange\CoreFramework\Debug\Debugger;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
use Org\Mxchange\CoreFramework\Output\Debug\BaseDebugOutput;
use Org\Mxchange\CoreFramework\Stream\Output\OutputStreamer;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*/
public function streamData (string $data) {
self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.');
- throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
}
// Import framework stuff
use Org\Mxchange\CoreFramework\Debug\Debugger;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
use Org\Mxchange\CoreFramework\Output\Debug\BaseDebugOutput;
use Org\Mxchange\CoreFramework\Stream\Output\OutputStreamer;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*/
public function streamData (string $data) {
self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.');
- throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
}
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
namespace Org\Mxchange\CoreFramework\Parser\Xml;
// Import framework stuff
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
+use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
use Org\Mxchange\CoreFramework\Parser\BaseParser;
use Org\Mxchange\CoreFramework\Parser\Parseable;
use Org\Mxchange\CoreFramework\Template\CompileableTemplate;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*/
public function parseXmlContent (string $content) {
// Convert all to UTF8
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('XML-PARSER: content()=%d - CALLED!', strlen($content)));
if (empty($content)) {
// No empty content
- throw new InvalidArgumentException('content is empty');
+ throw new InvalidArgumentException('content is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif (function_exists('recode')) {
// Recode found, so use it
$content = recode('html..utf8', $content);
$content = mb_convert_encoding($content, 'UTF-8', 'auto');
} else {
// @TODO We need to find a fallback solution here
- $this->partialStub('Cannot find recode/mbstring extension!');
+ DebugMiddleware::getSelfInstance()->partialStub('Cannot find recode/mbstring extension!');
}
// Get an XML parser
$xmlParser = xml_parser_create();
// Force case-folding to on
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('XML-PARSER: Created xmlParser=%s ...', $xmlParser));
xml_parser_set_option($xmlParser, XML_OPTION_CASE_FOLDING, TRUE);
// Set UTF-8
xml_set_character_data_handler($xmlParser, 'characterHandler');
// Now parse the XML tree
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('XML-PARSER: Invoking xml_parse(%s, content()=%d) ...', $xmlParser, strlen($content)));
if (!xml_parse($xmlParser, $content)) {
// Error found in XML
//* DEBUG: */ exit(__METHOD__ . ':<pre>'.htmlentities($content).'</pre>');
- throw new XmlParserException(array($this, $xmlParser), Parseable::EXCEPTION_XML_PARSER_ERROR);
+ throw new XmlParserException([$this, $xmlParser], Parseable::EXCEPTION_XML_PARSER_ERROR);
}
// Free the parser
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('XML-PARSER: Freeing xmlParser=%s ...', $xmlParser));
xml_parser_free($xmlParser);
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('XML-PARSER: EXIT!');
}
}
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
/**
* Instance of this class
*/
- private static $registryInstance = null;
+ private static $registryInstances = [];
/**
* Protected constructor
*
* @return $registryInstance Instance of this class
*/
- public final static function getRegistry () {
+ public final static function getRegistry (string $key) {
// Is an instance there?
- if (is_null(self::$registryInstance)) {
+ if (is_null(self::$registryInstances[$key])) {
// Not yet, so create one
- self::$registryInstance = new ???Registry();
+ self::$registryInstances[$key] = new ???Registry();
}
// Return the instance
- return self::$registryInstance;
+ return self::$registryInstances[$key];
}
}
// Import framework stuff
use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
-use Org\Mxchange\CoreFramework\Generic\NullPointerException;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
use Org\Mxchange\CoreFramework\Traits\Iterator\IteratorTrait;
// Import SPL stuff
use \InvalidArgumentExeption;
use \IteratorAggregate;
+use \UnexpectedValueException;
/**
* A general Registry
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*/
protected function __construct (string $className) {
// Call parent constructor
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-REGISTRY: className=%s - CONSTRUCTED!', $className));
parent::__construct($className);
// Init generic arrays
$this->initGenericArrayGroup('registry', 'generic');
- $this->initGenericArrayGroup('registry', 'instance');
+
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-REGISTRY: EXIT!');
}
/**
* @return $iteratorInstance An instance of a Iterator class
*/
public function getIterator (array $onlyRegistries = []) {
+ // Get iterator
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-REGISTRY: onlyRegistries()=%d - CALLED!', count($onlyRegistries)));
+ $iteratorInstance = $this->getIteratorInstance();
+
// Is it set?
- if (is_null($this->getIteratorInstance())) {
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-REGISTRY: iteratorInstance[]=%s', gettype($iteratorInstance)));
+ if (is_null($iteratorInstance)) {
// Then instance it
$iteratorInstance = ObjectFactory::createObjectByConfiguredName('registry_iterator_class', [$this]);
// ... and set it here
$this->setIteratorInstance($iteratorInstance);
- } else {
- // Use set iterator
- $iteratorInstance = $this->getIteratorInstance();
}
// Init iterator instance
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-REGISTRY: Invoking iteratorInstance->initIterator(onlyRegistries()=%d) ...', count($onlyRegistries)));
$iteratorInstance->initIterator($onlyRegistries);
// Return it
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-REGISTRY: iteratorInstance=%s - EXIT!', $iteratorInstance->__toString()));
return $iteratorInstance;
}
- /**
- * Checks whether an instance key was found
- *
- * @param $instanceKey The key holding an instance in registry
- * @return $exists Whether the key exists in registry
- */
- public function instanceExists (string $instanceKey) {
- // Does this key exists?
- $exists = $this->isGenericArrayKeySet('registry', 'instance', $instanceKey);
-
- // Return the result
- return $exists;
- }
-
- /**
- * Adds/overwrites a new instance to the registry at the given key
- *
- * @param $instanceKey The key to identify the instance
- * @param $objectInstance An instance we shall store
- * @return void
- */
- public function addInstance (string $instanceKey, Registerable $objectInstance) {
- // Validate parameter
- if (empty($instanceKey)) {
- // Throw IAE
- throw new InvalidArgumentExeption('Parameter "instanceKey" is empty');
- }
-
- // Set entry in generic array
- $this->setGenericArrayKey('registry', 'instance', $instanceKey, $objectInstance);
- }
-
/**
* Getter for whole generic registry
*
return $this->getGenericSubArray('registry', 'generic');
}
- /**
- * Getter for whole instance registry
- *
- * @return $instanceRegistry The whole instance registry array
- */
- public final function getInstanceRegistry () {
- return $this->getGenericSubArray('registry', 'instance');
- }
-
/**
* Adds a new entry to the given list name. If you want to add objects
* please use addInstance() and getInstance() instead.
* @param $key The key to identify the whole list
* @param $value The value to be stored
* @return void
+ * @throws InvalidArgumentException If a paramter has an invalid value
*/
public final function addEntry (string $key, $value) {
+ // Check parameter
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-REGISTRY: key=%s,value[]=%s - CALLED!', $key, gettype($value)));
+ if (empty($key)) {
+ // Throw IAE
+ throw new InvalidArgumentExeption('Parameter "key" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Push it
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-REGISTRY: Invoking this->pushValueToGenericArrayKey(registry,generic,%s,value[]=%s) ...', $key, gettype($value)));
$this->pushValueToGenericArrayKey('registry', 'generic', $key, $value);
+
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-REGISTRY: EXIT!');
}
/**
*
* @param $key Key
* @return $entries An array with entries from this registry
+ * @throws InvalidArgumentException If a paramter has an invalid value
*/
public final function getEntries (string $key = NULL) {
+ // Check parameter
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-REGISTRY: key[%s]=%s - CALLED!', gettype($key), $key));
+ if (!is_null($key) && empty($key)) {
+ // Throw IAE
+ throw new InvalidArgumentExeption('Parameter "key" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Default is whole array
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-REGISTRY: Invoking this->getGenericArray(registry) ...');
$entries = $this->getGenericArray('registry');
// Is $key set?
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-REGISTRY: key[]=%s,entries()=%d', $key, count($entries)));
if (!is_null($key)) {
// Then use this entry
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-REGISTRY: Invoking this->getGenericArrayKey(registry,generic,%s) ...', $key));
$entries = $this->getGenericArrayKey('registry', 'generic', $key);
}
// Return the array
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-REGISTRY: entries()=%d - EXIT!', count($entries)));
return $entries;
}
* @param $arrayKey The array (key) to look in
* @param $lookFor The key to look for
* @return $entry An array with all keys
+ * @throws InvalidArgumentException If a paramter has an invalid value
+ * @throws UnexpectedValueException If $value3 is not an array
*/
public function getArrayFromKey (string $arrayKey, string $lookFor) {
+ // Check parameter
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-REGISTRY: arrayKey=%s,lookFor=%s - CALLED!', $arrayKey, $lookFor));
+ if (empty($arrayKey)) {
+ // Throw IAE
+ throw new InvalidArgumentExeption('Parameter "arrayKey" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($lookFor)) {
+ // Throw IAE
+ throw new InvalidArgumentExeption('Parameter "lookFor" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Init array
$entry = [];
// "Walk" over all entries
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('REGISTRY: Checking arrayKey=' . $arrayKey . ',lookFor=' . $lookFor);
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-REGISTRY: Checking arrayKey=%s,lookFor=%s', $arrayKey, $lookFor));
foreach ($this->getEntries($arrayKey) as $key => $value) {
// If $value matches the $lookFor, we need to look for more entries for this!
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('REGISTRY: Checking key=' . $key . ',value=' . $value . ',lookFor=' . $lookFor);
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-REGISTRY: Checking key=%s,value=%s,lookFor=%s', $key, $value, $lookFor));
if ($lookFor == $value) {
// Look for more entries
foreach ($this->getEntries() as $key2 => $value2) {
// Now "walk" through all entries, if an array is returned
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-REGISTRY: key2=%s,value2[]=%s', $key2, gettype($value2)));
if (is_array($value2)) {
// "Walk" through all of them
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('REGISTRY: Checking key2=' . $key2 . ',value2()=' . count($value2) . ',lookFor=' . $lookFor);
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-REGISTRY: Checking key2=%s,value2()=%s,lookFor=%s', $key2, count($value2), $lookFor));
foreach ($value2 as $key3 => $value3) {
// $value3 needs to be an array
- assert(is_array($value3));
+ if (!is_array($value3)) {
+ // Throw exception
+ throw new UnexpectedValueException(sprintf('arrayKey=%s,key=%s,value=%s,key2=%s,key3=%s has unexpected value3[]=%s', $arrayKey, $key, $value, $key2, $key3, gettype($value3)), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
+ }
// Both keys must match!
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('REGISTRY: Checking key=' . $key . ',key3=' . $key3 . ',isset()=' . isset($value3[$key]) . ' ...');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-REGISTRY: Checking key=%s,key3=%s,isset()=%s ...', $key, $key3, intval(isset($value3[$key]))));
if (($key == $key3) || (isset($value3[$key]))) {
// Then add it
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('REGISTRY: Adding ' . $value3[$key] . ' ...');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-REGISTRY: Adding value3[%s]=%s ...', $key, $value3[$key]));
$entry[$key3] = $value3[$key];
}
}
}
// Skip further lookups
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('BASE-REGISTRY: BREAK!');
break;
}
}
// Return it
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('REGISTRY: Returning entry(' . count($entry) . ')=' . print_r($entry, true));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-REGISTRY: entry()=%d - EXIT!', count($entry)));
return $entry;
}
- /**
- * Gets a registered instance or null if not found
- *
- * @param $instanceKey The key to identify the instance
- * @return $objectInstance An instance we shall store
- * @throws NullPointerException If the requested key is not found
- */
- public function getInstance (string $instanceKey) {
- // Is the instance there?
- if (!$this->instanceExists($instanceKey)) {
- // This might happen if a non-registered key was requested
- throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
- }
-
- // Get the instance
- $objectInstance = $this->getGenericArrayKey('registry', 'instance', $instanceKey);
-
- // Return the result
- return $objectInstance;
- }
-
/**
* "Getter" for a registry key for given prefix and array. This method
* calls implode() to get a suitable key. This method does not care about
* @return $registryKey A registry key
*/
public static function getRegistryKeyFromArray (string $prefix, array $data) {
+ // Check parameter
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-REGISTRY: prefix=%s,data()=%d - CALLED!', $prefix, count($data)));
+ if (empty($prefix)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "prefix" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (count($data) == 0) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "data" is an empty array', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// "Generate" the key
$registryKey = $prefix . self::REGISTRY_KEY_GLUE . implode(self::REGISTRY_KEY_GLUE, $data);
// Return it
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-REGISTRY: registryKey=%s - EXIT!', $registryKey));
return $registryKey;
}
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
namespace Org\Mxchange\CoreFramework\Registry\Upgrade\Format\Lfdb;
// Import framework stuff
+use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
use Org\Mxchange\CoreFramework\Registry\BaseRegistry;
use Org\Mxchange\CoreFramework\Upgrade\Format\Database\UpgradeableDatabaseFormat;
use Org\Mxchange\CoreFramework\Upgrade\Format\RegisterableFormatUpgrade;
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
* @todo 0% done
*/
public function registerFormatUpgrader (UpgradeableDatabaseFormat $upgradeInstance) {
- $this->partialStub();
+ DebugMiddleware::getSelfInstance()->partialStub();
}
}
// Own namespace
namespace Org\Mxchange\CoreFramework\Registry;
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
+
/**
* A registry for several data types and objects. Objects should be added by
* addInstance() and therefore must implement the interface Registerable.
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
* Singleton getter for self instance. This class has no factory pattern
* because here is no need for special parameters.
*
+ * @param $key Key for for this instance
* @return $registryInstance Instance of this class
+ * @throws InvalidArgumentException If a parameter has an invalid value
*/
- public static final function getRegistry () {
+ public static final function getRegistry (string $key) {
+ // Check parameter
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('OBJECT-REGISTRY: key=%s - CALLED!', $key));
+ if (empty($key)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "key" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Is an instance there?
- if (is_null(self::$registryInstance)) {
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('OBJECT-REGISTRY: self::registryInstance[%s]?=%d', $key, intval(isset((self::$registryInstances[$key])))));
+ if (!isset(self::$registryInstances[$key])) {
// Not yet, so create one
- self::$registryInstance = new GenericRegistry();
+ self::$registryInstances[$key] = new ObjectRegistry();
}
// Return the instance
- return self::$registryInstance;
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('OBJECT-REGISTRY: self::registryInstance[%s]=%s - EXIT!', $key, self::$registryInstances[$key]->__toString()));
+ return self::$registryInstances[$key];
}
}
--- /dev/null
+<?php
+// Own namespace
+namespace Org\Mxchange\CoreFramework\Registry\Object;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
+use Org\Mxchange\CoreFramework\Generic\NullPointerException;
+use Org\Mxchange\CoreFramework\Registry\BaseRegistry;
+use Org\Mxchange\CoreFramework\Registry\Registerable;
+
+// Import SPL stuff
+use \InvalidArgumentException;
+
+/**
+ * A registry for several data types and objects. Objects should be added by
+ * addInstance() and therefore must implement the interface Registerable.
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 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 ObjectRegistry extends BaseRegistry implements ObjectRegister {
+ /**
+ * Instances of this class
+ */
+ private static $registryInstances = [];
+
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ private function __construct () {
+ // Call parent constructor
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('OBJECT-REGISTRY: CONSTRUCTED!');
+ parent::__construct(__CLASS__);
+
+ // Init own array
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('OBJECT-REGISTRY: Invoking this->initGenericArrayGroup(registry,instance) ...');
+ $this->initGenericArrayGroup('registry', 'instance');
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('OBJECT-REGISTRY: EXIT!');
+ }
+
+ /**
+ * Singleton getter for self instance. This class has no factory pattern
+ * because here is no need for special parameters.
+ *
+ * @param $key Key for for this instance
+ * @return $registryInstance Instance of this class
+ * @throws InvalidArgumentException If a parameter has an invalid value
+ */
+ public static final function getRegistry (string $key) {
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('OBJECT-REGISTRY: key=%s - CALLED!', $key));
+ if (empty($key)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "key" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
+ // Is an instance there?
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('OBJECT-REGISTRY: self::registryInstance[%s]?=%d', $key, intval(isset(self::$registryInstances[$key]))));
+ if (!isset(self::$registryInstances[$key])) {
+ // Not yet, so create one
+ self::$registryInstances[$key] = new ObjectRegistry();
+ }
+
+ // Return the instance
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('OBJECT-REGISTRY: self::registryInstance[%s]=%s - EXIT!', $key, self::$registryInstances[$key]->__toString()));
+ return self::$registryInstances[$key];
+ }
+
+ /**
+ * Checks whether an instance key was found
+ *
+ * @param $instanceKey The key holding an instance in registry
+ * @return $exists Whether the key exists in registry
+ * @throws InvalidArgumentException If a paramter has an invalid value
+ */
+ public function instanceExists (string $instanceKey) {
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('OBJECT-REGISTRY: instanceKey=%s - CALLED!', $instanceKey));
+ if (empty($instanceKey)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "instanceKey" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
+ // Does this key exists?
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('OBJECT-REGISTRY: Invoking this->isGenericArrayKeySet(registry, instance, %s) ...', $instanceKey));
+ $exists = $this->isGenericArrayKeySet('registry', 'instance', $instanceKey);
+
+ // Return the result
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('OBJECT-REGISTRY: exists=%d - EXIT!', intval($exists)));
+ return $exists;
+ }
+
+ /**
+ * Getter for whole instance registry
+ *
+ * @return $instanceRegistry The whole instance registry array
+ */
+ public final function getInstanceRegistry () {
+ return $this->getGenericSubArray('registry', 'instance');
+ }
+
+ /**
+ * Adds/overwrites a new instance to the registry at the given key
+ *
+ * @param $instanceKey The key to identify the instance
+ * @param $objectInstance An instance we shall store
+ * @return void
+ * @throws InvalidArgumentException If a paramter has an invalid value
+ */
+ public function addInstance (string $instanceKey, Registerable $objectInstance) {
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('OBJECT-REGISTRY: instanceKey=%s,objectInstance=%s - CALLED!', $instanceKey, $objectInstance->__toString()));
+ if (empty($instanceKey)) {
+ // Throw IAE
+ throw new InvalidArgumentExeption('Parameter "instanceKey" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
+ // Set entry in generic array
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('OBJECT-REGISTRY: Invoking this->setGenericArrayKey(registry,instance,%s,%s) ...', $instanceKey, $objectInstance->__toString()));
+ $this->setGenericArrayKey('registry', 'instance', $instanceKey, $objectInstance);
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('OBJECT-REGISTRY: EXIT!');
+ }
+
+ /**
+ * Gets a registered instance or null if not found
+ *
+ * @param $instanceKey The key to identify the instance
+ * @return $objectInstance An instance we shall store
+ * @throws InvalidArgumentException If a paramter has an invalid value
+ * @throws NullPointerException If the requested key is not found
+ */
+ public function getInstance (string $instanceKey) {
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('OBJECT-REGISTRY: instanceKey=%s - CALLED!', $instanceKey));
+ if (empty($instanceKey)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "instanceKey" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
+ // Is the instance there?
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('OBJECT-REGISTRY: Invoking this->instanceExists(%s) ...', $instanceKey));
+ if (!$this->instanceExists($instanceKey)) {
+ // This might happen if a non-registered key was requested
+ throw new NullPointerException($this, FrameworkInterface::EXCEPTION_IS_NULL_POINTER);
+ }
+
+ // Get the instance
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('OBJECT-REGISTRY: Invoking this->getGenericArrayKey(registry,instance,%s) ...', $instanceKey));
+ $objectInstance = $this->getGenericArrayKey('registry', 'instance', $instanceKey);
+
+ // Return the result
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('OBJECT-REGISTRY: objectInstance=%s - EXIT!', $objectInstance->__toString()));
+ return $objectInstance;
+ }
+
+}
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Own namespace
namespace Org\Mxchange\CoreFramework\Request;
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
+
/**
* A concrete request class
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
* @todo Needs to be implemented
*/
protected function prepareRequestData () {
- $this->partialStub("Please implement this method.");
+ DebugMiddleware::getSelfInstance()->partialStub("Please implement this method.");
}
/**
* @return $headerValue Value of the header or 'null' if not found
*/
public function getHeaderElement ($headerName) {
- $this->partialStub("Please implement this method.");
+ DebugMiddleware::getSelfInstance()->partialStub("Please implement this method.");
}
/**
* @return $requestMethod Used request method
*/
public final function getRequestMethod () {
- $this->partialStub("Please implement this method.");
+ DebugMiddleware::getSelfInstance()->partialStub("Please implement this method.");
return $_SERVER['REQUEST_METHOD'];
}
* @return $cookieValue Value of cookie or null if not found
*/
public final function readCookie ($cookieName) {
- $this->partialStub("Please implement this method.");
+ DebugMiddleware::getSelfInstance()->partialStub("Please implement this method.");
}
}
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
* valid so make sure your intercepting filters sets this attribute to false
* when they need to intercept the data flow.
*/
- private $requestIsValid = true;
+ private $isRequestValid = true;
/**
* Protected constructor
}
/**
- * Sets whether the request was valid (default: true)
+ * Sets whether the request was valid
*
* @param $isValid Whether the request is valid
* @return void
*/
- public final function requestIsValid (bool $isValid = true) {
- $this->requestIsValid = $isValid;
+ public final function setIsRequestValid (bool $isValid) {
+ $this->isRequestValid = $isValid;
}
/**
* Returns whether this request is valid
*
- * @return $requestIsValid Whether this request is valid
+ * @return $isRequestValid Whether this request is valid
*/
public final function isRequestValid () {
- return $this->requestIsValid;
+ return $this->isRequestValid;
}
}
namespace Org\Mxchange\CoreFramework\Request;
// Import framework stuff
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
use Org\Mxchange\CoreFramework\Request\Requestable;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*/
public function getHeaderElement (string $headerName) {
// Console doesn't have any headers
- throw new UnsupportedOperationException(array($this, __FUNCTION__, $executorInstance), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException(array($this, __FUNCTION__, $executorInstance), FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
*/
public final function readCookie (string $cookieName) {
// There are no cookies on console
- throw new UnsupportedOperationException(array($this, __FUNCTION__, $executorInstance), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException(array($this, __FUNCTION__, $executorInstance), FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
*/
public function isGetRequestMethod () {
// Not support method
- throw new UnsupportedOperationException(array($this, __FUNCTION__, $executorInstance), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException(array($this, __FUNCTION__, $executorInstance), FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
*/
public function isHeadRequestMethod () {
// Not support method
- throw new UnsupportedOperationException(array($this, __FUNCTION__, $executorInstance), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException(array($this, __FUNCTION__, $executorInstance), FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
*/
public function isPostRequestMethod () {
// Not support method
- throw new UnsupportedOperationException(array($this, __FUNCTION__, $executorInstance), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException(array($this, __FUNCTION__, $executorInstance), FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
}
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @todo Move out the cookie part to a seperate class, e.g. Cookie
// Import framework stuff
use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Resolver\BaseResolver;
use Org\Mxchange\CoreFramework\Utils\Strings\StringUtils;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Is a action set?
if (empty($namespace)) {
// Then thrown an exception here
- throw new InvalidArgumentException('Parameter "namespace" is empty');
+ throw new InvalidArgumentException('Parameter "namespace" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif (empty($actionName)) {
// Then thrown an exception here
- throw new InvalidArgumentException('Parameter "actionName" is empty');
+ throw new InvalidArgumentException('Parameter "actionName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
}
// Create class name
// Import framework stuff
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Request\Requestable;
// Import SPL stuff
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Is the variable $actionName set and the action is valid?
if (empty($actionName)) {
// Then thrown an exception here
- throw new InvalidArgumentException('Parameter "actionName" is empty');
+ throw new InvalidArgumentException('Parameter "actionName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif ($resolverInstance->isActionValid($actionName) === false) {
// Invalid action found
throw new InvalidActionException(array($resolverInstance, $actionName), self::EXCEPTION_INVALID_ACTION);
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
use Org\Mxchange\CoreFramework\Command\Commandable;
use Org\Mxchange\CoreFramework\Command\InvalidCommandException;
use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Request\Requestable;
use Org\Mxchange\CoreFramework\Resolver\BaseResolver;
use Org\Mxchange\CoreFramework\Utils\Strings\StringUtils;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// And validate it
if ((!is_object($commandInstance)) || (!$commandInstance instanceof Commandable)) {
// This command has an invalid instance!
- throw new UnexpectedValueException(sprintf('commandInstance for commandName=%s is not object (%s) or does not implement Commandable.', $commandName, gettype($commandInstance)), self::EXCEPTION_INVALID_COMMAND);
+ throw new UnexpectedValueException(sprintf('commandInstance for commandName=%s is not object (%s) or does not implement Commandable.', $commandName, gettype($commandInstance)), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
}
// Set last command
// Is a action set?
if (empty($namespace)) {
// Then thrown an exception here
- throw new InvalidArgumentException('Parameter "namespace" is empty');
+ throw new InvalidArgumentException('Parameter "namespace" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif (empty($commandName)) {
// Then thrown an exception here
- throw new InvalidArgumentException('Parameter "commandName" is empty');
+ throw new InvalidArgumentException('Parameter "commandName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
}
// Initiate the instance variable
// Is namespace and command name set?
if (empty($namespace)) {
// Then thrown an exception here
- throw new InvalidArgumentException('Parameter "namespace" is empty');
+ throw new InvalidArgumentException('Parameter "namespace" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif (empty($commandName)) {
// Then thrown an exception here
- throw new InvalidArgumentException('Parameter "commandName" is empty');
+ throw new InvalidArgumentException('Parameter "commandName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
}
// By default nothing shall be valid
// Import framework stuff
use Org\Mxchange\CoreFramework\Command\BaseCommand;
use Org\Mxchange\CoreFramework\Command\InvalidCommandException;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver;
// Import SPL stuff
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Is the variable $commandName set and the command is valid?
if (empty($namespace)) {
// Then thrown an exception here
- throw new InvalidArgumentException('Parameter "namespace" is empty');
+ throw new InvalidArgumentException('Parameter "namespace" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif (empty($commandName)) {
// Then thrown an exception here
- throw new InvalidArgumentException('Parameter "commandName" is empty');
+ throw new InvalidArgumentException('Parameter "commandName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif (!$resolverInstance->isCommandValid($namespace, $commandName)) {
// Invalid command found
throw new InvalidCommandException(array($resolverInstance, $commandName), self::EXCEPTION_INVALID_COMMAND);
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
// Import framework stuff
use Org\Mxchange\CoreFramework\Command\InvalidCommandException;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver;
// Import SPL stuff
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Is the variable $commandName set and the command is valid?
if (empty($commandName)) {
// Then thrown an exception here
- throw new InvalidArgumentException('Parameter "commandName" is empty');
+ throw new InvalidArgumentException('Parameter "commandName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif ($resolverInstance->isCommandValid($commandName) === false) {
// Invalid command found
// @TODO Missing namespace!
// Import framework stuff
use Org\Mxchange\CoreFramework\Command\InvalidCommandException;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver;
// Import SPL stuff
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Is the variable $commandName set and the command is valid?
if (empty($commandName)) {
// Then thrown an exception here
- throw new InvalidArgumentException('Parameter "commandName" is empty');
+ throw new InvalidArgumentException('Parameter "commandName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif ($resolverInstance->isCommandValid($commandName) === false) {
// @TODO Missing namespace!
// Invalid command found
use Org\Mxchange\CoreFramework\Controller\DefaultControllerException;
use Org\Mxchange\CoreFramework\Controller\InvalidControllerException;
use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
use Org\Mxchange\CoreFramework\Resolver\BaseResolver;
use Org\Mxchange\CoreFramework\Resolver\Controller\ControllerResolver;
use Org\Mxchange\CoreFramework\Utils\Strings\StringUtils;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Is a action set?
if (empty($namespace)) {
// Then thrown an exception here
- throw new InvalidArgumentException('Parameter "namespace" is empty');
+ throw new InvalidArgumentException('Parameter "namespace" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif (empty($controllerName)) {
// Then thrown an exception here
- throw new InvalidArgumentException('Parameter "controllerName" is empty');
+ throw new InvalidArgumentException('Parameter "controllerName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
}
// By default nothing shall be valid
// Import framework stuff
use Org\Mxchange\CoreFramework\Controller\BaseController;
use Org\Mxchange\CoreFramework\Controller\InvalidControllerException;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Resolver\Controller\ControllerResolver;
use Org\Mxchange\CoreFramework\Resolver\Controller\BaseControllerResolver;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Is the variable $controllerName set and the controller is valid?
if (empty($namespace)) {
// Then thrown an exception here
- throw new InvalidArgumentException('Parameter "namespace" is empty');
+ throw new InvalidArgumentException('Parameter "namespace" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif (empty($controllerName)) {
// Then thrown an exception here
- throw new InvalidArgumentException('Parameter "controllerName" is empty');
+ throw new InvalidArgumentException('Parameter "controllerName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif ($resolverInstance->isControllerValid($namespace, $controllerName) === false) {
// Invalid controller found
throw new InvalidControllerException(array($resolverInstance, $controllerName), self::EXCEPTION_INVALID_CONTROLLER);
// Import framework stuff
use Org\Mxchange\CoreFramework\Controller\BaseController;
use Org\Mxchange\CoreFramework\Controller\InvalidControllerException;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Resolver\Controller\ControllerResolver;
use Org\Mxchange\CoreFramework\Resolver\Controller\BaseControllerResolver;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Are all parameter set and the controller is valid?
if (empty($namespace)) {
// Then thrown an exception here
- throw new InvalidArgumentException('Parameter "namespace" is empty');
+ throw new InvalidArgumentException('Parameter "namespace" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif (empty($controllerName)) {
// Then thrown an exception here
- throw new InvalidArgumentException('Parameter "controllerName" is empty');
+ throw new InvalidArgumentException('Parameter "controllerName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif ($resolverInstance->isControllerValid($namespace, $controllerName) === false) {
// Invalid controller found
throw new InvalidControllerException(array($resolverInstance, $controllerName), self::EXCEPTION_INVALID_CONTROLLER);
// Import framework stuff
use Org\Mxchange\CoreFramework\Controller\BaseController;
use Org\Mxchange\CoreFramework\Controller\InvalidControllerException;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Resolver\Controller\ControllerResolver;
use Org\Mxchange\CoreFramework\Resolver\Controller\BaseControllerResolver;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Are all parameter set and the controller is valid?
if (empty($namespace)) {
// Then thrown an exception here
- throw new InvalidArgumentException('Parameter "namespace" is empty');
+ throw new InvalidArgumentException('Parameter "namespace" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif (empty($controllerName)) {
// Then thrown an exception here
- throw new InvalidArgumentException('Parameter "controllerName" is empty');
+ throw new InvalidArgumentException('Parameter "controllerName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif ($resolverInstance->isControllerValid($namespace, $controllerName) === false) {
// Invalid controller found
throw new InvalidControllerException(array($resolverInstance, $controllerName), self::EXCEPTION_INVALID_CONTROLLER);
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
/**
* A generic request class
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Import framework stuff
use Org\Mxchange\CoreFramework\Manager\ManageableApplication;
+use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
use Org\Mxchange\CoreFramework\Response\Responseable;
/**
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*/
public function addCookie (string $cookieName, $cookieValue, bool $encrypted = FALSE, int $expires = NULL) {
//* DEBUG: */ echo $cookieName.'='.$cookieValue."<br />\n";
- $this->partialStub('Naturally unimplemented in console response.');
+ DebugMiddleware::getSelfInstance()->partialStub('Naturally unimplemented in console response.');
}
/**
* @throws ResponseHeadersAlreadySentException If headers are already sent
*/
public function redirectToConfiguredUrl ($configEntry) {
- $this->partialStub('Naturally unimplemented in console response.');
+ DebugMiddleware::getSelfInstance()->partialStub('Naturally unimplemented in console response.');
}
/**
* @return void
*/
public function expireCookie ($cookieName) {
- $this->partialStub('Naturally unimplemented in console response.');
+ DebugMiddleware::getSelfInstance()->partialStub('Naturally unimplemented in console response.');
}
/**
* @return void
*/
public function refreshCookie ($cookieName) {
- $this->partialStub('Naturally unimplemented in console response.');
+ DebugMiddleware::getSelfInstance()->partialStub('Naturally unimplemented in console response.');
}
/**
* @throws ResponseHeadersAlreadySentException Thrown if headers are already sent
*/
public function flushBuffer ($force = false) {
- $this->partialStub('Please implement this class.');
+ DebugMiddleware::getSelfInstance()->partialStub('Please implement this class.');
}
}
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
use Org\Mxchange\CoreFramework\Manager\ManageableApplication;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
+use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
use Org\Mxchange\CoreFramework\Response\Responseable;
/**
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Shall we encrypt the cookie?
if ($encrypted) {
// Unsupported at the moment
- $this->partialStub('Encryption is unsupported at the moment.');
+ DebugMiddleware::getSelfInstance()->partialStub('Encryption is unsupported at the moment.');
}
// For slow browsers set the cookie array element first
use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
use Org\Mxchange\CoreFramework\Image\BaseImage;
use Org\Mxchange\CoreFramework\Manager\ManageableApplication;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
+use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
use Org\Mxchange\CoreFramework\Response\Responseable;
/**
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Shall we encrypt the cookie?
if ($encrypted) {
// Unsupported at the moment
- $this->partialStub('Encryption is unsupported at the moment.');
+ DebugMiddleware::getSelfInstance()->partialStub('Encryption is unsupported at the moment.');
}
// For slow browsers set the cookie array element first
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
$serverIp = 'cluster';
// Do we have a single server?
- if (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('is_single_server') == 'Y') {
+ if (FrameworkBootstrap::getConfigurationInstance()->isEnabled('single_server')) {
// Then use that IP for extra security
$serverIp = FrameworkBootstrap::detectServerAddress();
}
$key = md5($this->getExtraSalt());
// Get key
- if (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('crypt_fixed_salt') == 'Y') {
+ if (FrameworkBootstrap::getConfigurationInstance()->isEnabled('crypt_fixed_salt')) {
$key = md5($this->getFixedSalt());
}
namespace Org\Mxchange\CoreFramework\Stack\!!!;
// Import framework stuff
+use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
use Org\Mxchange\CoreFramework\Stack\BaseStacker;
use Org\Mxchange\CoreFramework\Stack\Stackable;
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
* @throws StackerFullException If the stack is full
*/
public function pushNamed ($stackerName, $value) {
- $this->partialStub('stackerName=' . $stackerName . ',value[' . gettype($value) . ']=' . $value);
+ DebugMiddleware::getSelfInstance()->partialStub('stackerName=' . $stackerName . ',value[' . gettype($value) . ']=' . $value);
}
/**
* @throws EmptyStackerException If the named stacker is empty
*/
public function popNamed ($stackerName) {
- $this->partialStub('stackerName=' . $stackerName);
+ DebugMiddleware::getSelfInstance()->partialStub('stackerName=' . $stackerName);
}
/**
* @throws EmptyStackerException If the named stacker is empty
*/
public function getNamed ($stackerName) {
- $this->partialStub('stackerName=' . $stackerName);
+ DebugMiddleware::getSelfInstance()->partialStub('stackerName=' . $stackerName);
}
}
// Import framework stuff
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
// Import SPL stuff
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
abstract class BaseStacker extends BaseFrameworkSystem {
- // Exception codes
- const EXCEPTION_STACKER_ALREADY_INITIALIZED = 0x050;
- const EXCEPTION_STACKER_IS_FULL = 0x051;
- const EXCEPTION_NO_STACKER_FOUND = 0x052;
- const EXCEPTION_STACKER_IS_EMPTY = 0x053;
-
/**
* Array "caches" configuration entries for saving "expensive" method
* invocations
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: stackerName=%s,forceReInit=%d - CALLED!', $stackerName, intval($forceReInit)));
if (empty($stackerName)) {
// No empty stack name
- throw new InvalidArgumentException('Parameter "stackerName" is empty');
+ throw new InvalidArgumentException('Parameter "stackerName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif (($forceReInit === false) && ($this->isStackInitialized($stackerName))) {
// Then throw the exception
- throw new BadMethodCallException(array($this, $stackerName, $forceReInit), self::EXCEPTION_STACKER_ALREADY_INITIALIZED);
+ throw new BadMethodCallException(array($this, $stackerName, $forceReInit), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
}
// Initialize the given stack and "cache" configuration entry
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: stacks()=%d,forceReInit=%d - CALLED!', count($stacks), intval($forceReInit)));
if (count($stacks) == 0) {
// No empty stack name
- throw new InvalidArgumentException('Array "stacks" is empty');
+ throw new InvalidArgumentException('Array "stacks" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
}
// "Walk" through all (more will be added as needed
foreach ($stacks as $stackerName) {
// Init this stack
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: Calling this->initStack(%s,%d) ...', $stackerName, intval($forceReInit)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: Invoking this->initStack(%s,%d) ...', $stackerName, intval($forceReInit)));
$this->initStack($stackerName, $forceReInit);
}
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: stackerName=%s - CALLED!', $stackerName));
if (empty($stackerName)) {
// No empty stack name
- throw new InvalidArgumentException('Parameter "stackerName" is empty');
+ throw new InvalidArgumentException('Parameter "stackerName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
}
// Is is there?
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: stackerName=%s - CALLED!', $stackerName));
if (empty($stackerName)) {
// No empty stack name
- throw new InvalidArgumentException('Parameter "stackerName" is empty');
+ throw new InvalidArgumentException('Parameter "stackerName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif (!$this->isStackInitialized($stackerName)) {
// Throw an exception
- throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), self::EXCEPTION_NO_STACKER_FOUND);
+ throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
}
// So, is the stack full?
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: stackerName=%s - CALLED!', $stackerName));
if (empty($stackerName)) {
// No empty stack name
- throw new InvalidArgumentException('Parameter "stackerName" is empty');
+ throw new InvalidArgumentException('Parameter "stackerName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif (!$this->isStackInitialized($stackerName)) {
// Throw an exception
- throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), self::EXCEPTION_NO_STACKER_FOUND);
+ throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
}
// So, is the stack empty?
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: stackerName=%s - CALLED!', $stackerName));
if (empty($stackerName)) {
// No empty stack name
- throw new InvalidArgumentException('Parameter "stackerName" is empty');
+ throw new InvalidArgumentException('Parameter "stackerName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif (!$this->isStackInitialized($stackerName)) {
// Throw an exception
- throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), self::EXCEPTION_NO_STACKER_FOUND);
+ throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
}
// Now, count the array of entries
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: stackerName=%s,value[]=%s - CALLED!', $stackerName, gettype($value)));
if (empty($stackerName)) {
// No empty stack name
- throw new InvalidArgumentException('Parameter "stackerName" is empty');
+ throw new InvalidArgumentException('Parameter "stackerName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif (!$this->isStackInitialized($stackerName)) {
// Throw an exception
- throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), self::EXCEPTION_NO_STACKER_FOUND);
+ throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
} elseif ($this->isStackFull($stackerName)) {
// Stacker is full
- throw new FullStackerException([$this, $stackerName, $value], self::EXCEPTION_STACKER_IS_FULL);
+ throw new BadMethodCallException(sprintf('stackerName=%s is full but method called.', $stackerName), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
}
// Now add the value to the stack
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: stackerName=%s - CALLED!', $stackerName));
if (empty($stackerName)) {
// No empty stack name
- throw new InvalidArgumentException('Parameter "stackerName" is empty');
+ throw new InvalidArgumentException('Parameter "stackerName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif (!$this->isStackInitialized($stackerName)) {
// Throw an exception
- throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), self::EXCEPTION_NO_STACKER_FOUND);
+ throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
} elseif ($this->isStackEmpty($stackerName)) {
// Throw an exception
- throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), self::EXCEPTION_STACKER_IS_EMPTY);
+ throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
}
+ // Calculate last index
+ $lastIndex = $this->getStackCount($stackerName) - 1;
+
// Now get the last value
- $value = $this->getGenericArrayElement('stacks', $stackerName, 'entries', $this->getStackCount($stackerName) - 1);
+ $value = $this->getGenericArrayElement('stacks', $stackerName, 'entries', $lastIndex);
// Return it
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: value[]=%s - EXIT!', gettype($value)));
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: stackerName=%s - CALLED!', $stackerName));
if (empty($stackerName)) {
// No empty stack name
- throw new InvalidArgumentException('Parameter "stackerName" is empty');
+ throw new InvalidArgumentException('Parameter "stackerName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif (!$this->isStackInitialized($stackerName)) {
// Throw an exception
- throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), self::EXCEPTION_NO_STACKER_FOUND);
+ throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
} elseif ($this->isStackEmpty($stackerName)) {
// Throw an exception
- throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), self::EXCEPTION_STACKER_IS_EMPTY);
+ throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
}
// Now get the first value
- $value = $this->getGenericArrayElement('stacks', $stackerName, 'entries', 0);
+ $value = $this->getGenericArrayElement('stacks', $stackerName, 'entries', '0');
// Return it
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: value[]=%s - EXIT!', gettype($value)));
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: stackerName=%s - CALLED!', $stackerName));
if (empty($stackerName)) {
// No empty stack name
- throw new InvalidArgumentException('Parameter "stackerName" is empty');
+ throw new InvalidArgumentException('Parameter "stackerName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif (!$this->isStackInitialized($stackerName)) {
// Throw an exception
- throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), self::EXCEPTION_NO_STACKER_FOUND);
+ throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
} elseif ($this->isStackEmpty($stackerName)) {
// Throw an exception
- throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), self::EXCEPTION_STACKER_IS_EMPTY);
+ throw new BadMethodCallException(sprintf('stackerName=%s is empty but method called.', $stackerName), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
}
// Now, remove the last entry, we don't care about the return value here, see elseif() block above
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: stackerName=%s - CALLED!', $stackerName));
if (empty($stackerName)) {
// No empty stack name
- throw new InvalidArgumentException('Parameter "stackerName" is empty');
+ throw new InvalidArgumentException('Parameter "stackerName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif (!$this->isStackInitialized($stackerName)) {
// Throw an exception
- throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), self::EXCEPTION_NO_STACKER_FOUND);
+ throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
} elseif ($this->isStackEmpty($stackerName)) {
// Throw an exception
- throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), self::EXCEPTION_STACKER_IS_EMPTY);
+ throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
}
// Now, remove the last entry, we don't care about the return value here, see elseif() block above
// Own namespace
namespace Org\Mxchange\CoreFramework\Stack;
+// Import framework-specific stuff
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
+
// Import SPL stuff
use \InvalidArgumentException;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
* @param $value Value to push on it
* @return void
* @throws InvalidArgumentException If a parameter is invalid
- * @throws StackerFullException If the stack is full
+ * @throws BadMethodCallException If the stack is full
*/
public function pushNamed (string $stackerName, $value) {
// Validate parameter
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: stackerName=%s,value[]=%s - CALLED!', $stackerName, gettype($value)));
if (empty($stackerName)) {
// No empty stack name
- throw new InvalidArgumentException('Parameter "stackerName" is empty');
+ throw new InvalidArgumentException('Parameter "stackerName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
}
// Call the protected method
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: Calling parent::addValueToStack(%s,%s) ...', $stackerName, gettype($value)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: Invoking parent::addValueToStack(%s,%s) ...', $stackerName, gettype($value)));
parent::addValueToStack($stackerName, $value);
// Trace message
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: stackerName=%s - CALLED!', $stackerName));
if (empty($stackerName)) {
// No empty stack name
- throw new InvalidArgumentException('Parameter "stackerName" is empty');
+ throw new InvalidArgumentException('Parameter "stackerName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
}
// Get the value
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: Calling this->getNamed(%s) ...', $stackerName));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: Invoking this->getNamed(%s) ...', $stackerName));
$value = $this->getNamed($stackerName);
// Call the protected method
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: Calling parent::popFirst(%s) ...', $stackerName));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: Invoking parent::popFirst(%s) ...', $stackerName));
parent::popFirst($stackerName);
// Return the value
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: stackerName=%s - CALLED!', $stackerName));
if (empty($stackerName)) {
// No empty stack name
- throw new InvalidArgumentException('Parameter "stackerName" is empty');
+ throw new InvalidArgumentException('Parameter "stackerName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
}
// Call the protected method
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: Calling parent::getFirstValue(%s) ...', $stackerName));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: Invoking parent::getFirstValue(%s) ...', $stackerName));
$value = parent::getFirstValue($stackerName);
// Return value
<?php
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
+
/**
* A ??? file-based stack
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2022 Core Developer Team
+ * @copyright Copyright (c) 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
* @throws StackerFullException If the stack is full
*/
public function pushNamed ($stackerName, $value) {
- $this->partialStub('stackerName=' . $stackerName . ',value[' . gettype($value) . ']=' . $value);
+ DebugMiddleware::getSelfInstance()->partialStub('stackerName=' . $stackerName . ',value[' . gettype($value) . ']=' . $value);
}
/**
* @throws EmptyStackerException If the named stacker is empty
*/
public function popNamed ($stackerName) {
- $this->partialStub('stackerName=' . $stackerName);
+ DebugMiddleware::getSelfInstance()->partialStub('stackerName=' . $stackerName);
}
/**
* @throws EmptyStackerException If the named stacker is empty
*/
public function getNamed ($stackerName) {
- $this->partialStub('stackerName=' . $stackerName);
+ DebugMiddleware::getSelfInstance()->partialStub('stackerName=' . $stackerName);
}
/**
* @return void
*/
public function seek ($seekPosition) {
- $this->partialStub('seekPosition=' . $seekPosition);
+ DebugMiddleware::getSelfInstance()->partialStub('seekPosition=' . $seekPosition);
}
/**
* @return $size Size (in bytes) of file
*/
public function size () {
- $this->partialStub();
+ DebugMiddleware::getSelfInstance()->partialStub();
}
}
use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
use Org\Mxchange\CoreFramework\Filesystem\File\BaseBinaryFile;
use Org\Mxchange\CoreFramework\Filesystem\File\BinaryFile;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
+use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
use Org\Mxchange\CoreFramework\Stack\BaseStacker;
use Org\Mxchange\CoreFramework\Traits\Index\IndexableTrait;
use Org\Mxchange\CoreFramework\Traits\Iterator\IteratorTrait;
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
strlen($data),
$data,
$this->getIteratorInstance()->getBinaryFileInstance()->getHeaderSize()
- ));
+ ), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
} elseif (empty(trim($data, chr(0)))) {
// Empty header, file is freshly pre-allocated
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-STACK: Empty file header detected - EXIT!');
throw new UnexpectedValueException(sprintf('data=%s does not have separator=0x%s at the end.',
$data,
dechex(BinaryFile::SEPARATOR_HEADER_ENTRIES)
- ));
+ ), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
}
// Okay, then remove it
$data = substr($data, 0, -1);
// And update seek position
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-STACK: Calling this->iteratorInstance->binaryFileInstance->updateSeekPosition() ...');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-STACK: Invoking this->iteratorInstance->binaryFileInstance->updateSeekPosition() ...');
$this->getIteratorInstance()->getBinaryFileInstance()->updateSeekPosition();
/*
$header = explode(chr(BinaryFile::SEPARATOR_HEADER_DATA), $data);
// Map numeric indexes to associative indexes
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: Calling ArrayUtils::mapNumericKeysToAssociative(%d) ...', count($header)));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: Invoking ArrayUtils::mapNumericKeysToAssociative(%d) ...', count($header)));
$header = ArrayUtils::mapNumericKeysToAssociative($header, [
BinaryFile::HEADER_NAME_MAGIC,
BinaryFile::HEADER_NAME_TOTAL_ENTRIES,
$data,
count($header),
BinaryFile::HEADER_STACK_ELEMENT_COUNT
- ));
+ ), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
} elseif ($header[BinaryFile::HEADER_NAME_MAGIC] != StackableFile::STACK_MAGIC) {
// Bad magic
throw new InvalidMagicException($data, self::EXCEPTION_BAD_MAGIC);
strlen($header[BinaryFile::HEADER_NAME_TOTAL_ENTRIES]),
$header[BinaryFile::HEADER_NAME_TOTAL_ENTRIES],
BinaryFile::LENGTH_COUNT
- ));
+ ), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
} elseif (strlen($header[BinaryFile::HEADER_NAME_SEEK_POSITION]) != BinaryFile::LENGTH_POSITION) {
// Position length not valid
throw new UnexpectedValueException(sprintf('header[%s](%d)=%s is not expected %d length',
strlen($header[BinaryFile::HEADER_NAME_SEEK_POSITION]),
$header[BinaryFile::HEADER_NAME_SEEK_POSITION],
BinaryFile::LENGTH_POSITION
- ));
+ ), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
}
// Decode count and seek position
);
// Write it to disk (header is always at seek position 0)
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: Calling this->iteratorInstance->writeAtPosition(0, header=%s) ...', $header));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: Invoking this->iteratorInstance->writeAtPosition(0, header=%s) ...', $header));
$this->getIteratorInstance()->getBinaryFileInstance()->writeAtPosition(0, $header);
// Trace message
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: fileInfoInstance[%s]=%s,type=%s - CALLED!', get_class($fileInfoInstance), $fileInfoInstance, $type));
if (empty($type)) {
// Invalid parameter
- throw new InvalidArgumentException('Parameter "type" is empty');
+ throw new InvalidArgumentException('Parameter "type" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
}
// Get a stack file instance
$this->getIteratorInstance()->getBinaryFileInstance()->setHeaderSize($headerSize);
// Init counters and gaps array
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-STACK: Calling this->iteratorInstance->initCountersGapsArray() ...');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-STACK: Invoking this->iteratorInstance->initCountersGapsArray() ...');
$this->getIteratorInstance()->getBinaryFileInstance()->initCountersGapsArray();
/*
// Is the file's header initialized?
if (!$this->getIteratorInstance()->getBinaryFileInstance()->isFileHeaderInitialized()) {
// First pre-allocate a bit
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-STACK: Calling this->iteratorInstance->preAllocateFile(file_stack) ...');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-STACK: Invoking this->iteratorInstance->preAllocateFile(file_stack) ...');
$this->getIteratorInstance()->getBinaryFileInstance()->preAllocateFile('file_stack');
// Then create file header
}
// Load the file header
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-STACK: Calling this->readStackHeader() ...');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-STACK: Invoking this->readStackHeader() ...');
$this->readStackHeader();
// Is the index loaded correctly, e.g. the stack file is just created?
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-STACK: Calling this->indexInstance->isIndexLoaded() ...');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-STACK: Invoking this->indexInstance->isIndexLoaded() ...');
if (!$this->getIndexInstance()->isIndexLoaded()) {
/*
* Something horrible has happened to the index as it should be
* loaded at this point. The stack's file structure then needs to
* be analyzed and the index rebuild.
*/
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-STACK: Calling this->iteratorInstance->analyzeFileStructure() ...');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-STACK: Invoking this->iteratorInstance->analyzeFileStructure() ...');
$this->getIteratorInstance()->getBinaryFileInstance()->analyzeFileStructure();
// Rebuild index from file
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: Calling this->iteratorInstance->rebuildIndexFromStack(%s) ...', $this->__toString()));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: Invoking this->iteratorInstance->rebuildIndexFromStack(%s) ...', $this->__toString()));
$this->getIndexInstance()->rebuildIndexFromStack($this);
}
//* PRINTR-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: stackerName=%s,value[%s]=%s', $stackerName, gettype($value), print_r($value, true)));
if (empty($stackerName)) {
// No empty stack name
- throw new InvalidArgumentException('Parameter "stackerName" is empty');
+ throw new InvalidArgumentException('Parameter "stackerName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif ($this->isStackFull($stackerName)) {
// Stacker is full
- throw new FullStackerException([$this, $stackerName, $value], self::EXCEPTION_STACKER_IS_FULL);
+ throw new BadMethodCallException(sprintf('stackerName=%s is full but method call.', $stackerName), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
} elseif (is_resource($value) || is_object($value)) {
// Not wanted type
throw new InvalidArgumentException(sprintf('value[]=%s is not supported', gettype($value)));
* Now add the value to the file stack which returns gap position, a
* hash and length of the raw data.
*/
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: Invoking this->iteratorInstance->binaryFileInstance->writeValueToFile(%s,value[]=%s) ...', $stackerName, gettype($value)));
$data = $this->getIteratorInstance()->getBinaryFileInstance()->writeValueToFile($stackerName, $value);
// Add the hash and gap position to the index
//* PRINTR-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: data=%s', print_r($data, true));
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: Calling this->indexInstance->addHashedDataToIndex(%s,data()=%d) ...', $stackerName, count($data)));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: Invoking this->indexInstance->addHashedDataToIndex(%s,data()=%d) ...', $stackerName, count($data)));
$this->getIndexInstance()->addHashedDataToIndex($stackerName, $data);
// Trace message
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: stackerName=%s - CALLED!', $stackerName));
if (empty($stackerName)) {
// No empty stack name
- throw new InvalidArgumentException('Parameter "stackerName" is empty');
+ throw new InvalidArgumentException('Parameter "stackerName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif ($this->isStackEmpty($stackerName)) {
// Throw an exception
- throw new BadMethodCallException([$this, $stackerName], self::EXCEPTION_STACKER_IS_EMPTY);
+ throw new BadMethodCallException([$this, $stackerName], FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
}
// Now get the last value
- /* NOISY-DEBUG: */ $this->partialStub('[' . __METHOD__ . ':' . __LINE__ . '] stackerName=' . $stackerName);
+ /* NOISY-DEBUG: */ DebugMiddleware::getSelfInstance()->partialStub('[' . __METHOD__ . ':' . __LINE__ . '] stackerName=' . $stackerName);
$value = NULL;
// Return it
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: stackerName=%s - CALLED!', $stackerName));
if (empty($stackerName)) {
// No empty stack name
- throw new InvalidArgumentException('Parameter "stackerName" is empty');
+ throw new InvalidArgumentException('Parameter "stackerName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif ($this->isStackEmpty($stackerName)) {
// Throw an exception
- throw new BadMethodCallException([$this, $stackerName], self::EXCEPTION_STACKER_IS_EMPTY);
+ throw new BadMethodCallException([$this, $stackerName], FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
}
// Now get the first value
- /* NOISY-DEBUG: */ $this->partialStub('[' . __METHOD__ . ':' . __LINE__ . '] stackerName=' . $stackerName);
+ /* NOISY-DEBUG: */ DebugMiddleware::getSelfInstance()->partialStub('[' . __METHOD__ . ':' . __LINE__ . '] stackerName=' . $stackerName);
$value = NULL;
// Return it
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: stackerName=%s - CALLED!', $stackerName));
if (empty($stackerName)) {
// No empty stack name
- throw new InvalidArgumentException('Parameter "stackerName" is empty');
+ throw new InvalidArgumentException('Parameter "stackerName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif ($this->isStackEmpty($stackerName)) {
// Throw an exception
- throw new BadMethodCallException([$this, $stackerName], self::EXCEPTION_STACKER_IS_EMPTY);
+ throw new BadMethodCallException([$this, $stackerName], FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
}
// Now, remove the last entry, we don't care about the return value here, see elseif() block above
- /* NOISY-DEBUG: */ $this->partialStub('[' . __METHOD__ . ':' . __LINE__ . '] stackerName=' . $stackerName);
+ /* NOISY-DEBUG: */ DebugMiddleware::getSelfInstance()->partialStub('[' . __METHOD__ . ':' . __LINE__ . '] stackerName=' . $stackerName);
return NULL;
}
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: stackerName=%s - CALLED!', $stackerName));
if (empty($stackerName)) {
// No empty stack name
- throw new InvalidArgumentException('Parameter "stackerName" is empty');
+ throw new InvalidArgumentException('Parameter "stackerName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif ($this->isStackEmpty($stackerName)) {
// Throw an exception
- throw new BadMethodCallException([$this, $stackerName], self::EXCEPTION_STACKER_IS_EMPTY);
+ throw new BadMethodCallException([$this, $stackerName], FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
}
// Now, remove the last entry, we don't care about the return value here, see elseif() block above
- /* NOISY-DEBUG: */ $this->partialStub('[' . __METHOD__ . ':' . __LINE__ . '] stackerName=' . $stackerName);
+ /* NOISY-DEBUG: */ DebugMiddleware::getSelfInstance()->partialStub('[' . __METHOD__ . ':' . __LINE__ . '] stackerName=' . $stackerName);
return NULL;
}
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: stackerName=%s - CALLED!', $stackerName));
if (empty($stackerName)) {
// No empty stack name
- throw new InvalidArgumentException('Parameter "stackerName" is empty');
+ throw new InvalidArgumentException('Parameter "stackerName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
}
// @TODO Please implement this, returning false
- /* NOISY-DEBUG: */ $this->partialStub('[' . __METHOD__ . ':' . __LINE__ . '] stackerName=' . $stackerName);
+ /* NOISY-DEBUG: */ DebugMiddleware::getSelfInstance()->partialStub('[' . __METHOD__ . ':' . __LINE__ . '] stackerName=' . $stackerName);
$isFull = false;
// Return result
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: stackerName=%s - CALLED!', $stackerName));
if (empty($stackerName)) {
// No empty stack name
- throw new InvalidArgumentException('Parameter "stackerName" is empty');
+ throw new InvalidArgumentException('Parameter "stackerName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
}
// So, is the stack empty?
* @throws UnsupportedOperationException This method is not (and maybe never will be) supported
*/
public function isStackInitialized (string $stackerName) {
- throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
* @throws UnsupportedOperationException This method is not (and maybe never will be) supported
*/
public function isEndOfFileReached () {
- throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
* @throws UnsupportedOperationException This method is not (and maybe never will be) supported
*/
public function initCountersGapsArray () {
- throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
* @throws UnsupportedOperationException This method is not (and maybe never will be) supported
*/
public final function getHeaderSize () {
- throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
* @throws UnsupportedOperationException This method is not (and maybe never will be) supported
*/
public final function setHeaderSize (int $headerSize) {
- throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
* @throws UnsupportedOperationException This method is not (and maybe never will be) supported
*/
public final function getHeader () {
- throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
* @throws UnsupportedOperationException This method is not (and maybe never will be) supported
*/
public final function setHeader (array $header) {
- throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
* @throws UnsupportedOperationException This method is not (and maybe never will be) supported
*/
public function updateSeekPosition () {
- throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
* @throws UnsupportedOperationException This method is not (and maybe never will be) supported
*/
public final function getCounter () {
- throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
*/
public function writeData (int $seekPosition, string $data, bool $flushHeader = true) {
// Not supported
- throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
*/
public function writeAtPosition (int $seekPosition, string $dataStream) {
// Not supported
- throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
* @throws UnsupportedOperationException This method is not (and maybe never will be) supported
*/
public function writeValueToFile (string $stackName, $value) {
- throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
*/
public function searchNextGap (int $length) {
// Not supported here
- throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
* @param $hash Hash from encoded value
* @param $encoded Encoded value to be written to the file
* @return $data Gap position and length of the raw data
+ * @throws InvalidArgumentException If a parameter has an invalid value
*/
public function writeDataToFreeGap (string $stackName, string $hash, string $encoded) {
- // Raw data been written to the file
+ // Check parameter
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: stackName=%s,hash{}=0x%s,encoded()=%d - CALLED!', $stackName, bin2hex($hash), strlen($encoded)));
+ if (empty($stackName)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "stackName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($hash)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "hash" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($encoded)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "encoded" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
+ // Raw data been written to the file
$rawData = sprintf('%s%s%s%s%s',
$stackName,
BinaryFile::SEPARATOR_GROUP_HASH,
gettype($gapPosition),
$gapPosition,
$this->getIteratorInstance()->getBinaryFileInstance()->getHeaderSize()
- ));
+ ), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
}
// Then write the data at that gap
// Import framework stuff
use Org\Mxchange\CoreFramework\Filesystem\Block\CalculatableBlock;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
+use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
use Org\Mxchange\CoreFramework\Registry\Registerable;
use Org\Mxchange\CoreFramework\Stack\File\BaseFileStack;
use Org\Mxchange\CoreFramework\Stack\File\StackableFile;
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2022 Core Developer Team
+ * @copyright Copyright (c) 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FIFO-FILE-STACK: fileInfoInstance[%s]=%s,type=%s - CALLED!', get_class($fileInfoInstance), $fileInfoInstance, $type));
if (empty($type)) {
// No empty type
- throw new InvalidArgumentException('Parameter "type" is empty');
+ throw new InvalidArgumentException('Parameter "type" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
}
// Get new instance
$stackInstance = new FiFoFileStack();
// Init this stack
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FIFO-FILE-STACK: Calling stackInstance->initFileStack([%s]=%s,%s) ...', get_class($fileInfoInstance), $fileInfoInstance, $type));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FIFO-FILE-STACK: Invoking stackInstance->initFileStack([%s]=%s,%s) ...', get_class($fileInfoInstance), $fileInfoInstance, $type));
$stackInstance->initFileStack($fileInfoInstance, $type);
// Return the prepared instance
* @param $value Value to push on it
* @return void
* @throws InvalidArgumentException If a parameter is invalid
- * @throws StackerFullException If the stack is full
+ * @throws BadMethodCallException If the stack is full
*/
public function pushNamed (string $stackerName, $value) {
// Validate parameter
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FIFO-FILE-STACK: stackerName=%s,value[]=%s - CALLED!', $stackerName, gettype($value)));
if (empty($stackerName)) {
// No empty stack name
- throw new InvalidArgumentException('Parameter "stackerName" is empty');
+ throw new InvalidArgumentException('Parameter "stackerName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif (is_object($value) || is_resource($value)) {
// Those types for $value are not allowed
throw new InvalidArgumentException(sprintf('value[]=%s is not valid', gettype($value)));
}
// Call the protected method
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FIFO-FILE-STACK: Calling parent::addValueToStack(%s,%s) ...', $stackerName, gettype($value)));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FIFO-FILE-STACK: Invoking parent::addValueToStack(%s,%s) ...', $stackerName, gettype($value)));
parent::addValueToStack($stackerName, $value);
// Trace message
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FIFO-FILE-STACK: stackerName=%s - CALLED!', $stackerName));
if (empty($stackerName)) {
// No empty stack name
- throw new InvalidArgumentException('Parameter "stackerName" is empty');
+ throw new InvalidArgumentException('Parameter "stackerName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
}
// Get the value
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FIFO-FILE-STACK: stackerName=%s - CALLED!', $stackerName));
if (empty($stackerName)) {
// No empty stack name
- throw new InvalidArgumentException('Parameter "stackerName" is empty');
+ throw new InvalidArgumentException('Parameter "stackerName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
}
// Call the protected method
}
// @TODO Unfinished method or invoke inner iterator's method?
- $this->partialStub('seekPosition=' . $seekPosition);
+ DebugMiddleware::getSelfInstance()->partialStub('seekPosition=' . $seekPosition);
// Trace message
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FIFO-FILE-STACK: EXIT!');
// Own namespace
namespace Org\Mxchange\CoreFramework\Stack;
+// Import framework-specific stuff
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
+
/**
* A FiLo Stacker class
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
* @param $value Value to push on it
* @return void
* @throws InvalidArgumentException If a parameter is invalid
- * @throws StackerFullException If the stack is full
+ * @throws BadMethodCallException If the stack is full
*/
public function pushNamed (string $stackerName, $value) {
// Validate parameter
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILO-FILE-STACK: stackerName=%s,value[]=%s - CALLED!', $stackerName, gettype($value)));
if (empty($stackerName)) {
// No empty stack name
- throw new InvalidArgumentException('Parameter "stackerName" is empty');
+ throw new InvalidArgumentException('Parameter "stackerName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
}
// Call the protected method
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILO-FILE-STACK: Calling parent::addValueToStack(%s,%s) ...', $stackerName, gettype($value)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILO-FILE-STACK: Invoking parent::addValueToStack(%s,%s) ...', $stackerName, gettype($value)));
parent::addValueToStack($stackerName, $value);
// Trace message
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILO-FILE-STACK: stackerName=%s - CALLED!', $stackerName));
if (empty($stackerName)) {
// No empty stack name
- throw new InvalidArgumentException('Parameter "stackerName" is empty');
+ throw new InvalidArgumentException('Parameter "stackerName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
}
// Get the value
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILO-FILE-STACK: stackerName=%s - CALLED!', $stackerName));
if (empty($stackerName)) {
// No empty stack name
- throw new InvalidArgumentException('Parameter "stackerName" is empty');
+ throw new InvalidArgumentException('Parameter "stackerName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
}
// Call the protected method
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
// Import framework stuff
use Org\Mxchange\CoreFramework\Executor\Executor;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
use Org\Mxchange\CoreFramework\State\Stateable;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
* @throws UnsupportedOperationException This method should be overwritten
*/
public function executeState (Executor $executorInstance) {
- throw new UnsupportedOperationException(array($this, __FUNCTION__, $executorInstance), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException(array($this, __FUNCTION__, $executorInstance), FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
}
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
+++ /dev/null
-<?php
-// Own namespace
-namespace Org\Mxchange\CoreFramework\Stream\Crypto\Mcrypt;
-
-// Import framework stuff
-use Org\Mxchange\CoreFramework\Crypto\RandomNumber\RandomNumberGenerator;
-use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
-use Org\Mxchange\CoreFramework\Stream\Crypto\BaseCryptoStream;
-use Org\Mxchange\CoreFramework\Stream\Crypto\EncryptableStream;
-
-/**
- * A mcrypt-based encryption stream
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.org
- * @todo mcrypt will become deprecated, rewrite to OpenSSL
- *
- * 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 McryptStream extends BaseCryptoStream implements EncryptableStream {
- /**
- * Protected constructor
- *
- * @return void
- */
- private function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this node class
- *
- * @param $rngInstance An RNG instance
- * @return $streamInstance An instance of this node class
- */
- public static final function createMcryptStream (RandomNumberGenerator $rngInstance) {
- // Get a new instance
- $streamInstance = new McryptStream();
-
- // Set the RNG instance
- $streamInstance->setRngInstance($rngInstance);
-
- // Return the instance
- return $streamInstance;
- }
-
- /**
- * Encrypt the string with fixed salt
- *
- * @param $str The unencrypted string
- * @param $key Optional key, if none provided, a random key will be generated
- * @return $encrypted Encrypted string
- */
- public function encryptStream (string $str, string $key = NULL) {
- // Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MCRYPT-STREAM: key[' . gettype($key) . ']=' . $key);
-
- // Init crypto module
- $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
- $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
-
- // Generate key, if none provided
- if (is_null($key)) {
- // None provided
- $key = $this->getRngInstance()->generateKey();
- }
-
- // Add some "payload" to the string
- switch ($this->getRngInstance()->randomNumber(0, 8)) {
- case 0:
- $payloadString = crc32($this->getRngInstance()->randomString(10)) . EncryptableStream::DATA_PAYLOAD_SEPARATOR . base64_encode($str) . EncryptableStream::DATA_PAYLOAD_SEPARATOR . crc32($this->getRngInstance()->randomString(20));
- break;
-
- case 1:
- $payloadString = crc32($this->getRngInstance()->randomString(10)) . EncryptableStream::DATA_PAYLOAD_SEPARATOR . base64_encode($str) . EncryptableStream::DATA_PAYLOAD_SEPARATOR . md5($this->getRngInstance()->randomString(20));
- break;
-
- case 2:
- $payloadString = crc32($this->getRngInstance()->randomString(10)) . EncryptableStream::DATA_PAYLOAD_SEPARATOR . base64_encode($str) . EncryptableStream::DATA_PAYLOAD_SEPARATOR . sha1($this->getRngInstance()->randomString(20));
- break;
-
- case 3:
- $payloadString = md5($this->getRngInstance()->randomString(10)) . EncryptableStream::DATA_PAYLOAD_SEPARATOR . base64_encode($str) . EncryptableStream::DATA_PAYLOAD_SEPARATOR . crc32($this->getRngInstance()->randomString(20));
- break;
-
- case 4:
- $payloadString = md5($this->getRngInstance()->randomString(10)) . EncryptableStream::DATA_PAYLOAD_SEPARATOR . base64_encode($str) . EncryptableStream::DATA_PAYLOAD_SEPARATOR . md5($this->getRngInstance()->randomString(20));
- break;
-
- case 5:
- $payloadString = md5($this->getRngInstance()->randomString(10)) . EncryptableStream::DATA_PAYLOAD_SEPARATOR . base64_encode($str) . EncryptableStream::DATA_PAYLOAD_SEPARATOR . sha1($this->getRngInstance()->randomString(20));
- break;
-
- case 6:
- $payloadString = sha1($this->getRngInstance()->randomString(10)) . EncryptableStream::DATA_PAYLOAD_SEPARATOR . base64_encode($str) . EncryptableStream::DATA_PAYLOAD_SEPARATOR . crc32($this->getRngInstance()->randomString(20));
- break;
-
- case 7:
- $payloadString = sha1($this->getRngInstance()->randomString(10)) . EncryptableStream::DATA_PAYLOAD_SEPARATOR . base64_encode($str) . EncryptableStream::DATA_PAYLOAD_SEPARATOR . md5($this->getRngInstance()->randomString(20));
- break;
-
- case 8:
- $payloadString = sha1($this->getRngInstance()->randomString(10)) . EncryptableStream::DATA_PAYLOAD_SEPARATOR . base64_encode($str) . EncryptableStream::DATA_PAYLOAD_SEPARATOR . sha1($this->getRngInstance()->randomString(20));
- break;
- }
-
- // Encrypt the string
- $encrypted = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $payloadString, MCRYPT_MODE_ECB, $iv);
-
- // Return the string
- return $encrypted;
- }
-
- /**
- * Decrypt the string with fixed salt
- *
- * @param $encrypted Encrypted string
- * @param $key Optional key, if none provided, a random key will be generated
- * @return $str The unencrypted string
- */
- public function decryptStream (string $encrypted, string $key = NULL) {
- // Init crypto module
- $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
- $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
-
- // Shall we use a default key or custom?
- if (is_null($key)) {
- // Generate (default) key
- $key = $this->getRngInstance()->generateKey();
- }
-
- // Decrypt the string
- $payloadString = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $encrypted, MCRYPT_MODE_ECB, $iv);
-
- // Get the real string out
- $strArray = explode(EncryptableStream::DATA_PAYLOAD_SEPARATOR, $payloadString);
-
- // Does the element count match?
- assert(count($strArray) == 3);
-
- // Decode the string
- $str = base64_decode($strArray[1]);
-
- // Trim trailing nulls away
- $str = rtrim($str, "\0");
-
- // Return the string
- return $str;
- }
-
- /**
- * Streams the data and maybe does something to it
- *
- * @param $data The data (string mostly) to "stream"
- * @return $data The data (string mostly) to "stream"
- * @throws UnsupportedOperationException If this method is called (which is a mistake)
- */
- public function streamData (string $data) {
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.');
- throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
- }
-
-}
namespace Org\Mxchange\CoreFramework\Stream\Crypto\Null;
// Import framework stuff
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
use Org\Mxchange\CoreFramework\Stream\Crypto\BaseCryptoStream;
use Org\Mxchange\CoreFramework\Stream\Crypto\EncryptableStream;
/**
- * A null-encryption stream does not encrypt anything but can be used if e.e.
- * mcrypt is not installed.
+ * A null-encryption stream does not encrypt anything but can be used if e.g.
+ * openssl is not installed.
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
*/
public function streamData (string $data) {
self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.');
- throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
}
// Import framework stuff
use Org\Mxchange\CoreFramework\Crypto\RandomNumber\RandomNumberGenerator;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
use Org\Mxchange\CoreFramework\Stream\Crypto\BaseCryptoStream;
use Org\Mxchange\CoreFramework\Stream\Crypto\EncryptableStream;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*/
public function streamData (string $data) {
self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.');
- throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
}
namespace Tld\Domain\Project\Task\___;
// Import framework stuff
+use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
use Org\Mxchange\CoreFramework\Task\BaseTask;
use Org\Mxchange\CoreFramework\Task\Taskable;
use Org\Mxchange\CoreFramework\Visitor\Visitable;
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
* @todo 0%
*/
public function executeTask () {
- $this->partialStub('Unimplemented task.');
+ DebugMiddleware::getSelfInstance()->partialStub('Unimplemented task.');
}
/**
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
use Org\Mxchange\CoreFramework\EntryPoint\ApplicationEntryPoint;
use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
use Org\Mxchange\CoreFramework\Filesystem\FileNotFoundException;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Generic\NullPointerException;
use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
use Org\Mxchange\CoreFramework\Manager\ManageableApplication;
use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
use Org\Mxchange\CoreFramework\Response\Responseable;
use Org\Mxchange\CoreFramework\Traits\Handler\Io\IoHandlerTrait;
use Org\Mxchange\CoreFramework\Utils\Strings\StringUtils;
// Import SPL stuff
+use \BadMethodCallException;
use \InvalidArgumentException;
use \SplFileInfo;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
const EXCEPTION_INVALID_VIEW_HELPER = 0x112;
const EXCEPTION_VARIABLE_IS_MISSING = 0x113;
+ /**
+ * HTML template type
+ */
+ private static $htmlTemplateType = 'invalid';
+
/**
* The local path name where all templates and sub folders for special
* templates are stored. We will internally determine the language plus
*/
protected function __construct (string $className) {
// Call parent constructor
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: className=%s - CONSTRUCTED!', $className));
parent::__construct($className);
// Init file I/O instance
$ioInstance = ObjectFactory::createObjectByConfiguredName('file_io_class');
// Set it
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: ioInstance=%s', $ioInstance->__toString()));
$this->setFileIoInstance($ioInstance);
+
+ // "Cache" config entry
+ self::$htmlTemplateType = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('html_template_type');
+
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: self::htmlTemplateType=%s - EXIT!', self::$htmlTemplateType));
}
/**
*/
private function getVariableIndex (string $variableName, string $variableGroup = NULL) {
// Replace all dashes to underscores to match variables with configuration entries
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: variableName=%s,variableGroup[%s]=%s - CALLED!', $variableName, gettype($variableGroup), $variableGroup));
$variableName = trim(StringUtils::convertDashesToUnderscores($variableName));
// First everything is not found
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-TEMPLATE: variableName=%s', $variableName));
$found = false;
// If the stack is NULL, use the current group
if (is_null($variableGroup)) {
// Use current group
- //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(__METHOD__.' currGroup=' . $this->currGroup . ' set as stack!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-TEMPLATE: this->currGroup=%s set as stack!', $this->currGroup));
$variableGroup = $this->currGroup;
}
// Is the group there?
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-TEMPLATE: variableGroup=%s', $variableGroup));
if ($this->isVarStackSet($variableGroup)) {
// Now search for it
foreach ($this->getVarStack($variableGroup) as $index => $currEntry) {
- //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(__METHOD__.':currGroup=' . $variableGroup . ',idx=' . $index . ',currEntry=' . $currEntry['name'] . ',variableName=' . $variableName);
// Is the entry found?
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-TEMPLATE: index=%d,currGroup=%s,currEntry[name]=%s,variableName=%s', $index, $variableGroup, $currEntry['name'], $variableName));
if ($currEntry['name'] == $variableName) {
// Found!
- //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(__METHOD__.':FOUND!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-TEMPLATE: index=%d - BREAK!', $index));
$found = $index;
break;
}
}
// Return the current position
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: found=%d - EXIT!', $found));
return $found;
}
*
* @param $variableGroup Variable group to check
* @return $isSet Whether the given variable group is set
+ * @throws InvalidArgumentException If the variable name is left empty
*/
protected final function isVarStackSet (string $variableGroup) {
+ // Validate parameter
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: variableGroup=%s - CALLED!', $variableGroup));
+ if (empty($variableGroup)) {
+ // Throw an exception
+ throw new InvalidArgumentException('Parameter "variableGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Check it
- $isSet = isset($this->varStack[$variableGroup]);
+ $isset = isset($this->varStack[$variableGroup]);
// Return result
- return $isSet;
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: isset=%d - EXIT!', intval($isset)));
+ return $isset;
}
/**
*
* @param $variableGroup Variable group to check
* @return $varStack Found variable group
+ * @throws InvalidArgumentException If the variable name is left empty
*/
public final function getVarStack (string $variableGroup) {
+ // Validate parameter
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: variableGroup=%s - CALLED!', $variableGroup));
+ if (empty($variableGroup)) {
+ // Throw an exception
+ throw new InvalidArgumentException('Parameter "variableGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
+ // Return value
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: this->varStack[%s]()=%d - EXIT!', $variableGroup, count($this->varStack[$variableGroup])));
return $this->varStack[$variableGroup];
}
* @param $variableGroup Variable group to check
* @param $varStack Variable stack to check
* @return void
+ * @throws InvalidArgumentException If the variable name is left empty
*/
protected final function setVarStack (string $variableGroup, array $varStack) {
+ // Validate parameter
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: variableGroup=%s,varStack()=%d - CALLED!', $variableGroup, count($varStack)));
+ if (empty($variableGroup)) {
+ // Throw an exception
+ throw new InvalidArgumentException('Parameter "variableGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
+ // Set var stack
$this->varStack[$variableGroup] = $varStack;
+
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-TEMPLATE: EXIT!');
}
/**
* @param $variableName The variable we are looking for
* @param $variableGroup Optional variable group to look in
* @return $content Content of the variable or null if not found
+ * @throws InvalidArgumentException If the variable name is left empty
*/
protected function readVariable (string $variableName, string $variableGroup = NULL) {
+ // Check parameters
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: variableName=%s,variableGroup[%s]=%s - CALLED!', $variableName, gettype($variableGroup), $variableGroup));
+ if (empty($variableName)) {
+ // Throw an exception
+ throw new InvalidArgumentException('Parameter "variableName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (!is_null($variableGroup) && empty($variableGroup)) {
+ // Throw an exception
+ throw new InvalidArgumentException('Parameter "variableGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Replace all dashes to underscores to match variables with configuration entries
$variableName = trim(StringUtils::convertDashesToUnderscores($variableName));
// First everything is not found
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-TEMPLATE: variableName=%s', $variableName));
$content = NULL;
// If the stack is NULL, use the current group
if (is_null($variableGroup)) {
// Use current group
- //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(__METHOD__.' currGroup=' . $this->currGroup . ' set as stack!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-TEMPLATE: this->currGroup=%s set as stack!', $this->currGroup));
$variableGroup = $this->currGroup;
}
$found = $this->getVariableIndex($variableName, $variableGroup);
// Is the variable found?
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-TEMPLATE: found[]=%s', gettype($found)));
if ($found !== false) {
// Read it
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: Invoking this->getVariableValue(%s,%s) ...', $variableGroup, $found));
$content = $this->getVariableValue($variableGroup, $found);
}
// Return the current position
- //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(__METHOD__.': variableGroup=' . $variableGroup . ',variableName=' . $variableName . ', content[' . gettype($content) . ']=' . $content);
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: content()=%d - EXIT!', strlen($content)));
return $content;
}
*/
private function addVariable (string $variableName, $value) {
// Set general variable group
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: variableName=%s,value[]=%s - CALLED!', $variableName, gettype($value)));
$this->setVariableGroup('general');
// Add it to the stack
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: Invoking this->addVariableGroup(%s,value[]=%s) ...', $variableName, gettype($value)));
$this->addGroupVariable($variableName, $value);
+
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-TEMPLATE: EXIT!');
}
/**
*/
private function readCurrentGroup () {
// Default is not found
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-TEMPLATE: CALLED!');
$result = [];
// Is the group there?
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-TEMPLATE: this->currGroup=%s', $this->currGroup));
if ($this->isVarStackSet($this->currGroup)) {
// Then use it
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: Invoking this->getVarStack(%s) ...', $this->currGroup));
$result = $this->getVarStack($this->currGroup);
}
// Return result
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: result()=%d - EXIT!', count($result)));
return $result;
}
* @param $groupName Name of variable group
* @param $add Whether add this group
* @return void
+ * @throws InvalidArgumentException If the variable name is left empty
*/
public function setVariableGroup (string $groupName, bool $add = true) {
+ // Check parameter
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: groupName=%s,add=%d - CALLED!', $groupName, intval($add)));
+ if (empty($groupName)) {
+ // Throw an exception
+ throw new InvalidArgumentException('Parameter "groupName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Set group name
- //* DEBIG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(__METHOD__.': currGroup=' . $groupName);
$this->currGroup = $groupName;
// Skip group 'general'
if (($groupName != 'general') && ($add === true)) {
+ // Mark as 'OK'
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-TEMPLATE: Marking groupName=%s as OK ...', $groupdName));
$this->variableGroups[$groupName] = 'OK';
}
- }
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-TEMPLATE: EXIT!');
+ }
/**
* Adds a variable to current group
* @param $variableName Variable to set
* @param $value Value to store in variable
* @return void
+ * @throws InvalidArgumentException If the variable name is left empty
*/
public function addGroupVariable (string $variableName, $value) {
+ // Check parameter
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: variableName=%s,value[]=%s - CALLED!', $variableName, gettype($value)));
+ if (empty($variableName)) {
+ // Throw an exception
+ throw new InvalidArgumentException('Parameter "variableName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (is_object($value) || is_resource($value)) {
+ // Throw an exception
+ throw new InvalidArgumentException(sprintf('value[]=%s is not supported', gettype($value)), FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Replace all dashes to underscores to match variables with configuration entries
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: Invoking StringUtils::convertDashesToUnderscores(%s) ...', $variableName));
$variableName = trim(StringUtils::convertDashesToUnderscores($variableName));
- // Debug message
- //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(__METHOD__.': group=' . $this->currGroup . ', variableName=' . $variableName . ', value=' . $value);
-
// Get current variables in group
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-TEMPLATE: this->currGroup=%s,variableName=%s,value[]=%s', $this->currGroup, $variableName, gettype($value)));
$currVars = $this->readCurrentGroup();
// Append our variable
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-TEMPLATE: currVars()=%d - BEFORE!', count($currVars)));
array_push($currVars, $this->generateVariableArray($variableName, $value));
// Add it to the stack
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: Invoking this->setVarStack(%s,currVars()=%d) - AFTER!', $this->currGroup, count($currVars)));
$this->setVarStack($this->currGroup, $currVars);
+
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-TEMPLATE: EXIT!');
}
/**
* Getter for variable value, throws a NoVariableException if the variable is not found
*
* @param $variableGroup Variable group to use
- * @param $index Index in variable array
- * @return $value Value to set
+ * @param $index Index in variable array
+ * @return $value Value to set
*/
private function getVariableValue (string $variableGroup, int $index) {
// Return it
- return $this->varStack[$variableGroup][$index]['value'];
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: variableGroup=%s,index[]=%d - CALLED!', $variableGroup, $index));
+ $value = $this->varStack[$variableGroup][$index]['value'];
+
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: value[]=%s - EXIT!', gettype($value)));
+ return $value;
}
/**
* @param $variableName The variable we are looking for
* @param $value The value we want to store in the variable
* @return void
- * @throws NoVariableException If the given variable is not found
*/
private function modifyVariable (string $variableName, $value) {
// Replace all dashes to underscores to match variables with configuration entries
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: variableName=%s,value[]=%s - CALLED!', $variableName, gettype($value)));
$variableName = trim(StringUtils::convertDashesToUnderscores($variableName));
// Get index for variable
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: this->getVariableIndex(%s) ...', $variableName));
$index = $this->getVariableIndex($variableName);
- // Is the variable set?
- if ($index === false) {
- // Unset variables cannot be modified
- throw new NoVariableException(array($this, $variableName, $value), self::EXCEPTION_VARIABLE_IS_MISSING);
- }
-
// Then modify it
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: this->setVariableValue(%s,%d,value[]=%s) ...', $this->currGroup, $index, gettype($value)));
$this->setVariableValue($this->currGroup, $index, $value);
+
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-TEMPLATE: EXIT!');
}
/**
* @return void
*/
private function setVariableValue (string $variableGroup, int $index, $value) {
+ // Set variable
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: variableGroup=%s,index[]=%d,value[]=%s - CALLED!', $variableGroup, $index, gettype($value)));
$this->varStack[$variableGroup][$index]['value'] = $value;
+
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-TEMPLATE: EXIT!');
}
/**
* @param $variableName Variable to set
* @param $value Value to set
* @return void
+ * @throws InvalidArgumentException If the variable name is left empty
*/
protected function setVariable (string $variableGroup, string $variableName, $value) {
+ // Check parameters
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: variableGroup=%s,variableName=%s,value[]=%s - CALLED!', $variableGroup, $variableName, gettype($value)));
+ if (empty($variableGroup)) {
+ // Throw an exception
+ throw new InvalidArgumentException('Parameter "variableGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($variableName)) {
+ // Throw an exception
+ throw new InvalidArgumentException('Parameter "variableName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Replace all dashes to underscores to match variables with configuration entries
$variableName = trim(StringUtils::convertDashesToUnderscores($variableName));
// Get index for variable
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: this->getVariableIndex(%s) ...', $variableName));
$index = $this->getVariableIndex($variableName);
// Is the variable set?
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-TEMPLATE: index[]=%s', gettype($index)));
if ($index === false) {
// Is the stack there?
if (!isset($this->varStack[$variableGroup])) {
// Then initialize it here
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-TEMPLATE: Initializing this->varStack[%s] ...', $variableGroup));
$this->varStack[$variableGroup] = [];
}
// Not found, add it
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-TEMPLATE: Pushing variableGroup=%s,variableName=%s,value[]=%s ...', $variableGroup, $variableName, gettype($value)));
array_push($this->varStack[$variableGroup], $this->generateVariableArray($variableName, $value));
} else {
// Then modify it
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: Invoking this->setVariableValue(%s,%d,value[]=%s) ...', $this->currGroup, $index, gettype($value)));
$this->setVariableValue($this->currGroup, $index, $value);
}
+
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-TEMPLATE: EXIT!');
}
/**
*/
private function generateVariableArray (string $variableName, $value) {
// Replace all dashes to underscores to match variables with configuration entries
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: variableName=%s,value[]=%s - CALLED!', $variableName, gettype($value)));
$variableName = trim(StringUtils::convertDashesToUnderscores($variableName));
// Generate the temporary array
- $varData = array(
+ $varData = [
'name' => $variableName,
'value' => $value
- );
+ ];
// And return it
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: varData()=%d - EXIT!', count($varData)));
return $varData;
}
* @param $index Index to unset
* @param $variableGroup Variable group (default: currGroup)
* @return void
+ * @throws InvalidArgumentException If the variable name is left empty
+ * @throws BadMethodCallException If this method was called but combination of variableGroup/index isn't found
*/
protected final function unsetVariableStackOffset (int $index, string $variableGroup = NULL) {
+ // Check variables
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: index=%d,variableGroup[%s]=%s - CALLED!', $index, gettype($variableGroup), $variableGroup));
+ if ($index < 0) {
+ // Invalid index
+ throw new InvalidArgumentException(sprintf('index=%d is below zero', $index), FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (!is_null($variableGroup) && empty($variableGroup)) {
+ // Throw an exception
+ throw new InvalidArgumentException('Parameter "variableGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Is the variable group not set?
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-TEMPLATE: variableGroup[]=%s', gettype($variableGroup)));
if (is_null($variableGroup)) {
// Then set it to current
$variableGroup = $this->currGroup;
}
// Is the entry there?
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-TEMPLATE: Checking variableGroup=%s,index=%d ...', $variableGroup, $index));
if (!isset($this->varStack[$variableGroup][$index])) {
// Abort here, we need fixing!
- $this->debugInstance();
+ throw new BadMethodCallException(sprintf('variableGroup=%s,index=%d does not exist, but method was invoked', $variableGroup, $index), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
}
// Remove it
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-TEMPLATE: Unsetting variableGroup=%s,index=%d ...', $variableGroup, $index));
unset($this->varStack[$variableGroup][$index]);
+
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-TEMPLATE: EXIT!');
}
/**
*/
protected final function setRawTemplateData (string $rawTemplateData) {
// And store it in this class
- //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(__METHOD__.': ' . strlen($rawTemplateData) . ' Bytes set.');
- //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(__METHOD__.': ' . $this->currGroup . ' variables: ' . count($this->getVarStack($this->currGroup)) . ', groups=' . count($this->varStack));
$this->rawTemplateData = $rawTemplateData;
}
* @return $rawTemplateData The raw data from the template
*/
public final function getRawTemplateData () {
- //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-TEMPLATE: ' . strlen($this->rawTemplateData) . ' Bytes read.');
return $this->rawTemplateData;
}
*/
private final function setCompiledData (string $compiledData) {
// And store it in this class
- //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-TEMPLATE: ' . strlen($compiledData) . ' Bytes set.');
$this->compiledData = $compiledData;
}
* @return $compiledData Compiled template data
*/
public final function getCompiledData () {
- //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-TEMPLATE: ' . strlen($this->compiledData) . ' Bytes read.');
return $this->compiledData;
}
* @param $templateName The template we shall load
* @param $extOther An other extension to use
* @return void
+ * @throws InvalidArgumentException If the variable name is left empty
* @throws FileNotFoundException If the template was not found
*/
protected function loadTemplate (string $templateName, string $extOther = '') {
+ // Check parameter
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: templateName=%s,extOther=%s - CALLED!', $templateName, $extOther));
+ if (empty($templateName)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "templateName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Get extension for the template if empty
if (empty($extOther)) {
// None provided, so get the raw one
* now entirely done by php_intl. These old thing with language-based
* template paths comes from an older time.
*/
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-TEMPLATE: ext=%s', $ext));
$fileInstance = new SplFileInfo(sprintf('%s%s%s%s%s%s',
$this->getTemplateBasePath(),
$this->getGenericBasePath(),
));
// First try this
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-TEMPLATE: fileInstance=%s', $fileInstance->__toString()));
try {
// Load the raw template data
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: Invoking this->loadRawTemplateData(%s) ...', $fileInstance->__toString()));
$this->loadRawTemplateData($fileInstance);
} catch (FileNotFoundException $e) {
// If we shall load a code-template we need to switch the file extension
- if (($this->getTemplateType() != FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('html_template_type')) && (empty($extOther))) {
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-TEMPLATE: this->templateType=%s,self::htmlTemplateType=%s,extOther=%s', $this->getTemplateType(), self::$htmlTemplateType, $extOther));
+ if (($this->getTemplateType() != self::$htmlTemplateType) && (empty($extOther))) {
// Switch over to the code-template extension and try it again
$ext = $this->getCodeTemplateExtension();
// Try it again...
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: Invoking this->loadTemplate(%s,%s) ...', $templateName, $ex));
$this->loadTemplate($templateName, $ext);
} else {
// Throw it again
}
}
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-TEMPLATE: EXIT!');
}
/**
*/
private function loadRawTemplateData (SplFileInfo $fileInstance) {
// Load the raw template
- //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-TEMPLATE: fileInstance=' . $fileInstance);
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: fileInstance=%s - CALLED!', $fileInstance->__toString()));
$rawTemplateData = $this->getFileIoInstance()->loadFileContents($fileInstance);
// Store the template's contents into this class
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: Invoking this->setRawTemplateData(%d) ...', strlen($rawTemplateData)));
$this->setRawTemplateData($rawTemplateData);
// Remember the template's file instance
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: Invoking this->setLastTemplate(%s) ...', $fileInstance->__toString()));
$this->setLastTemplate($fileInstance);
+
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-TEMPLATE: EXIT!');
}
/**
*
* @param $variableName The variable's name (shall be content or config)
* by default
- * @param $variableName The variable we want to assign
+ * @param $configKey Possible configuration key
* @return void
*/
- private function assignTemplateVariable (string $variableName, $var) {
+ private function assignTemplateVariable (string $variableName, string $configKey = '') {
// Replace all dashes to underscores to match variables with configuration entries
- //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-TEMPLATE: variableName=' . $variableName . ',var=' . $var);
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: variableName=%s,configKey=%s - CALLED!', $variableName, $configKey));
$variableName = trim(StringUtils::convertDashesToUnderscores($variableName));
// Is it not a config variable?
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-TEMPLATE: variableName=%s', $variableName));
if ($variableName != 'config') {
// Regular template variables
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: Invoking this->assignVariable(%s,"") ...', $variableName));
$this->assignVariable($variableName, '');
} else {
// Configuration variables
- $this->assignConfigVariable($var);
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: Invoking this->assignConfigVariable(%s,"") ...', $configKey));
+ $this->assignConfigVariable($configKey);
}
+
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-TEMPLATE: EXIT!');
}
/**
*/
private function extractVariablesFromRawData (string $rawData) {
// Search for variables
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-TEMPLATE:rawData(' . strlen($rawData) . ')=' . $rawData . ',variableMatches=' . print_r($variableMatches, true));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: rawData(%d)=%s - CALLED!', strlen($rawData), $rawData));
preg_match_all('/\$(\w+)(\[(\w+)\])?/', $rawData, $variableMatches);
// Did we find some variables?
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-TEMPLATE: variableMatches[]=%s', gettype($variableMatches)));
if ((is_array($variableMatches)) && (count($variableMatches) == 4) && (count($variableMatches[0]) > 0)) {
// Initialize all missing variables
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-TEMPLATE: variableMatches()=%d', count($variableMatches)));
foreach ($variableMatches[3] as $key => $var) {
// Variable name
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-TEMPLATE: key=%s,var=%s', $key, $var));
$variableName = $variableMatches[1][$key];
// Workarround: Do not assign empty variables
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-TEMPLATE: variableName=%s', $variableName));
if (!empty($var)) {
// Try to assign it, empty strings are being ignored
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: Invoking this->assignTemplateVariable(%s,%s) ...', $variableName, $var));
$this->assignTemplateVariable($variableName, $var);
}
}
}
+
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-TEMPLATE: EXIT!');
}
/**
*/
private function analyzeTemplate (array $templateMatches) {
// Backup raw template data
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: templateMatches()=%d', count($templateMatches)));
$backup = $this->getRawTemplateData();
// Initialize some arrays
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-TEMPLATE: backup[%s]()=%d,this->loadedRawData[]=%s', gettype($backup), strlen($backup), gettype($this->loadedRawData)));
if (is_null($this->loadedRawData)) {
// Initialize both
$this->loadedRawData = [];
}
// Load all requested templates
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-TEMPLATE: templateMatches[1]()=%d', count($templateMatches[1])));
foreach ($templateMatches[1] as $template) {
// Load and compile only templates which we have not yet loaded
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-TEMPLATE: template=%s', $template));
// RECURSIVE PROTECTION! BE CAREFUL HERE!
if ((!isset($this->loadedRawData[$template])) && (!in_array($template, $this->loadedTemplates))) {
- // Debug message
- //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-TEMPLATE:template=' . $template);
-
// Template not found, but maybe variable assigned?
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-TEMPLATE: template=%s not loaded yet', $template));
if ($this->getVariableIndex($template) !== false) {
// Use that content here
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-TEMPLATE: Assigning this->loadedTemplateData[%s] from variable template=%s ...', $template, $template));
$this->loadedRawData[$template] = $this->readVariable($template);
// Recursive protection:
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-TEMPLATE: Marking template=%s as loaded ...', $template));
array_push($this->loadedTemplates, $template);
} else {
// Then try to search for code-templates
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-TEMPLATE: template=%s is maybe name of code template?', $template));
try {
- // Load the code template and remember it's contents
+ // Load the code template ...
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: Invoking this->loadCodeTemplate(%s) ...', $template));
$this->loadCodeTemplate($template);
+
+ // ... and remember it's contents
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-TEMPLATE: Setting this->loadedRawData[%s] from this->rawTemplateData ...', $template));
$this->loadedRawData[$template] = $this->getRawTemplateData();
// Remember this template for recursion detection
// RECURSIVE PROTECTION!
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-TEMPLATE: Marking template=%s as loaded ...', $template));
array_push($this->loadedTemplates, $template);
} catch (FileNotFoundException $e) {
// Even this is not done... :/
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-TEMPLATE: Marking template=%s as loaded ...', $template));
array_push($this->rawTemplates, $template);
}
}
}
// Restore the raw template data
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: Invoking this->setRawTemplateData(backup()=%d) ...', strlen($backup)));
$this->setRawTemplateData($backup);
+
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-TEMPLATE: EXIT!');
}
/**
*/
private function compileCode (string $code, string $template) {
// Is this template already compiled?
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: code=%s,template=%s - CALLED!', $code, $template));
if (in_array($template, $this->compiledTemplates)) {
// Abort here...
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: Found template=%s in this->compiledTemplates - EXIT!', $template));
return;
}
// Remember this template being compiled
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-TEMPLATE: Adding template=%s to this->compiledTemplates ...', $template));
array_push($this->compiledTemplates, $template);
// Compile the loaded code in five steps:
//
// 1. Backup current template data
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-TEMPLATE: this->compiledTemplates()=%d', count($this->compiledTemplates)));
$backup = $this->getRawTemplateData();
// 2. Set the current template's raw data as the new content
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: Invoking this->setRawTemplateData(code()=%d) ... - backup[%s]()=%d', strlen($code), gettype($backup), strlen($backup)));
$this->setRawTemplateData($code);
// 3. Compile the template data
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-TEMPLATE: Invoking this->compileTemplate() ...');
$this->compileTemplate();
// 4. Remember it's contents
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-TEMPLATE: Setting this->loadedRawData[%s] from this->rawTemplateData ...', $template));
$this->loadedRawData[$template] = $this->getRawTemplateData();
// 5. Restore the previous raw content from backup variable
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: Invoking this->setRawTemplateData(backup()=%d) ...', strlen($backup)));
$this->setRawTemplateData($backup);
+
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-TEMPLATE: EXIT!');
}
/**
*/
private function insertAllTemplates (array $templateMatches) {
// Run through all loaded codes
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: templateMatches()=%d', count($templateMatches)));
foreach ($this->loadedRawData as $template => $code) {
-
// Search for the template
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-TEMPLATE: template=%s,code()=%d', $template, strlen($code)));
$foundIndex = array_search($template, $templateMatches[1]);
// Lookup the matching template replacement
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-TEMPLATE: foundIndex[%s]=d', gettype($foundIndex), $foundIndex));
if (($foundIndex !== false) && (isset($templateMatches[0][$foundIndex]))) {
-
// Get the current raw template
$rawData = $this->getRawTemplateData();
// Replace the space holder with the template code
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-TEMPLATE: rawData()=%s - BEFORE!', strlen($rawData)));
$rawData = str_replace($templateMatches[0][$foundIndex], $code, $rawData);
// Set the new raw data
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-TEMPLATE: rawData()=%s - AFTER!', strlen($rawData)));
$this->setRawTemplateData($rawData);
}
}
+
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-TEMPLATE: EXIT!');
}
/**
* @todo Unfinished work or don't die here.
*/
private function assignAllVariables (array $varMatches) {
- // Debug message
- //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-TEMPLATE:varMatches()=' . count($varMatches));
-
// Search for all variables
+ //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-TEMPLATE:varMatches()=' . count($varMatches));
foreach ($varMatches[1] as $key => $var) {
// Replace all dashes to underscores to match variables with configuration entries
$var = trim(StringUtils::convertDashesToUnderscores($var));
* @return void
*/
private function compileRawTemplateData (array $templateMatches) {
- // Debug message
- //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-TEMPLATE:loadedRawData()= ' .count($this->loadedRawData));
-
// Are some code-templates found which we need to compile?
+ //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-TEMPLATE:loadedRawData()= ' .count($this->loadedRawData));
if (count($this->loadedRawData) > 0) {
// Then compile all!
foreach ($this->loadedRawData as $template => $code) {
$content = $this->getRawTemplateData();
//* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-TEMPLATE: content before=' . strlen($content) . ' (' . md5($content) . ')');
- // Do we have the stack?
- if (!$this->isVarStackSet('general')) {
- // Abort here silently
- // @TODO This silent abort should be logged, maybe.
- return;
- }
-
// Walk through all variables
foreach ($this->getVarStack('general') as $currEntry) {
//* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-TEMPLATE: name=' . $currEntry['name'] . ', value=<pre>' . htmlentities($currEntry['value']) . '</pre>');
* @param $template The web template we shall load which is located in
* 'html' by default
* @return void
+ * @throws InvalidArgumentException If the variable name is left empty
*/
public function loadHtmlTemplate (string $template) {
+ // Validate parameter
+ if (empty($template)) {
+ // Throw an exception
+ throw new InvalidArgumentException('Parameter "template" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Set template type
- $this->setTemplateType(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('html_template_type'));
+ $this->setTemplateType(self::$htmlTemplateType);
// Load the special template
$this->loadTemplate($template);
// Validate parameter
if (empty($variableName)) {
// Throw an exception
- throw new InvalidArgumentException('Parameter "variableName" is empty');
+ throw new InvalidArgumentException('Parameter "variableName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
}
// Replace all dashes to underscores to match variables with configuration entries
* @param $variableName The variable we are looking for
* @param $variableGroup Name of variable group (default: 'general')
* @return void
+ * @throws InvalidArgumentException If the variable name is left empty
*/
public final function removeVariable (string $variableName, string $variableGroup = 'general') {
+ // Validate parameter
+ if (empty($variableName)) {
+ // Throw an exception
+ throw new InvalidArgumentException('Parameter "variableName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($variableGroup)) {
+ // Throw an exception
+ throw new InvalidArgumentException('Parameter "variableGroup" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// First search for the variable if it was already added
$index = $this->getVariableIndex($variableName, $variableGroup);
* @param $templateName Name of the template we want to assign
* @param $variableName Name of the variable we want to assign
* @return void
+ * @throws InvalidArgumentException If the variable name is left empty
*/
public function assignTemplateWithVariable (string $templateName, string $variableName) {
+ // Validate parameter
+ if (empty($templateName)) {
+ // Throw an exception
+ throw new InvalidArgumentException('Parameter "templateName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($variableName)) {
+ // Throw an exception
+ throw new InvalidArgumentException('Parameter "variableName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Get the content from last loaded raw template
$content = $this->getRawTemplateData();
*
* @param $variableName The configuration variable we want to assign
* @return void
+ * @throws InvalidArgumentException If the variable name is left empty
*/
public function assignConfigVariable (string $variableName) {
+ // Validate parameter
+ if (empty($variableName)) {
+ // Throw an exception
+ throw new InvalidArgumentException('Parameter "variableName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Replace all dashes to underscores to match variables with configuration entries
$variableName = trim(StringUtils::convertDashesToUnderscores($variableName));
* @param $template The code template we shall load which is
* located in 'code' by default
* @return void
+ * @throws InvalidArgumentException If the variable name is left empty
*/
public function loadCodeTemplate (string $template) {
+ // Validate parameter
+ if (empty($template)) {
+ // Throw an exception
+ throw new InvalidArgumentException('Parameter "template" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Set template type
$this->setTemplateType(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('code_' . FrameworkBootstrap::getRequestTypeFromSystem() . '_template_type'));
* @param $template The email template we shall load which is
* located in 'emails' by default
* @return void
+ * @throws InvalidArgumentException If the variable name is left empty
*/
public function loadEmailTemplate (string $template) {
+ // Validate parameter
+ if (empty($template)) {
+ // Throw an exception
+ throw new InvalidArgumentException('Parameter "template" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Set template type
$this->setTemplateType(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('email_template_type'));
*
* @param $helperName The helper's name
* @return void
+ * @throws InvalidArgumentException If the variable name is left empty
*/
protected function loadViewHelper (string $helperName) {
+ // Validate parameter
+ if (empty($helperName)) {
+ // Throw an exception
+ throw new InvalidArgumentException('Parameter "helperName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Is this view helper loaded?
if (!isset($this->helpers[$helperName])) {
// Create a class name
* @param $rawCode Raw code to compile
* @param $setMatchAsCode Sets $match if readVariable() returns empty result
* @return $rawCode Compile code with inserted variable value
+ * @throws InvalidArgumentException If the variable name is left empty
*/
public function compileRawCode (string $rawCode, bool $setMatchAsCode = false) {
+ // Validate parameter
+ if (empty($rawCode)) {
+ // Throw an exception
+ throw new InvalidArgumentException('Parameter "rawCode" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Find the variables
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-TEMPLATE:rawCode=<pre>' . htmlentities($rawCode) . '</pre>');
preg_match_all($this->regExpVarValue, $rawCode, $varMatches);
* @param $oldName Old name of variable
* @param $newName New name of variable
* @return void
+ * @throws InvalidArgumentException If the variable name is left empty
*/
public function renameVariable (string $oldName, string $newName) {
+ // Validate parameter
//* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-TEMPLATE: oldName=' . $oldName . ', newName=' . $newName);
+ if (empty($oldName)) {
+ // Throw an exception
+ throw new InvalidArgumentException('Parameter "oldName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($newName)) {
+ // Throw an exception
+ throw new InvalidArgumentException('Parameter "newName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Get raw template code
$rawData = $this->getRawTemplateData();
* @return $compactedContent The compacted content
*/
public function compactContent (string $uncompactedContent) {
+ // Validate parameter
+ if (empty($uncompactedContent)) {
+ // Throw an exception
+ throw new InvalidArgumentException('Parameter "uncompactedContent" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// First, remove all tab/new-line/revert characters
$compactedContent = str_replace(chr(9), '', str_replace(chr(10), '', str_replace(chr(13), '', $uncompactedContent)));
// Import framework stuff
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
use Org\Mxchange\CoreFramework\Filesystem\InvalidDirectoryException;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
use Org\Mxchange\CoreFramework\Template\CompileableTemplate;
use Org\Mxchange\CoreFramework\Template\Engine\BaseTemplateEngine;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @todo This template engine does not make use of setTemplateType()
// Is the base path valid?
if (empty($templateBasePath)) {
// Base path is empty
- throw new UnexpectedValueException(sprintf('[%s:%d] Variable templateBasePath is empty.', $templateInstance->__toString(), __LINE__), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
+ throw new UnexpectedValueException(sprintf('[%s:%d] Variable templateBasePath is empty.', $templateInstance->__toString(), __LINE__), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
} elseif (!is_dir($templateBasePath)) {
// Is not a path
throw new InvalidDirectoryException(array($templateInstance, $templateBasePath), self::EXCEPTION_INVALID_PATH_NAME);
// Import framework stuff
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
use Org\Mxchange\CoreFramework\Filesystem\InvalidDirectoryException;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
use Org\Mxchange\CoreFramework\Template\CompileableTemplate;
use Org\Mxchange\CoreFramework\Template\Engine\BaseTemplateEngine;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Is the base path valid?
if (empty($templateBasePath)) {
// Base path is empty
- throw new UnexpectedValueException(sprintf('[%s:%d] Variable templateBasePath is empty.', $templateInstance->__toString(), __LINE__), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
+ throw new UnexpectedValueException(sprintf('[%s:%d] Variable templateBasePath is empty.', $templateInstance->__toString(), __LINE__), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
} elseif (!is_dir($templateBasePath)) {
// Is not a path
throw new InvalidDirectoryException(array($templateInstance, $templateBasePath), self::EXCEPTION_INVALID_PATH_NAME);
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
use Org\Mxchange\CoreFramework\Filesystem\InvalidDirectoryException;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
use Org\Mxchange\CoreFramework\Image\BaseImage;
+use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
use Org\Mxchange\CoreFramework\Parser\Parseable;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
use Org\Mxchange\CoreFramework\Response\Responseable;
use Org\Mxchange\CoreFramework\Template\CompileableTemplate;
use Org\Mxchange\CoreFramework\Template\Engine\BaseTemplateEngine;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Is the base path valid?
if (empty($templateBasePath)) {
// Base path is empty
- throw new UnexpectedValueException(sprintf('[%s:%d] Variable templateBasePath is empty.', $templateInstance->__toString(), __LINE__), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
+ throw new UnexpectedValueException(sprintf('[%s:%d] Variable templateBasePath is empty.', $templateInstance->__toString(), __LINE__), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
} elseif (!is_dir($templateBasePath)) {
// Is not a path
throw new InvalidDirectoryException(array($templateInstance, $templateBasePath), self::EXCEPTION_INVALID_PATH_NAME);
}
// Unfinished work!
- $this->partialStub('Handling extra characters is not yet supported!');
+ DebugMiddleware::getSelfInstance()->partialStub('Handling extra characters is not yet supported!');
}
/**
// Import framework stuff
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
use Org\Mxchange\CoreFramework\Filesystem\InvalidDirectoryException;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
use Org\Mxchange\CoreFramework\Mailer\DeliverableMail;
use Org\Mxchange\CoreFramework\Parser\Parseable;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
use Org\Mxchange\CoreFramework\Response\Responseable;
use Org\Mxchange\CoreFramework\Template\CompileableTemplate;
use Org\Mxchange\CoreFramework\Template\Engine\BaseTemplateEngine;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @todo This template engine does not make use of setTemplateType()
// Is the base path valid?
if (empty($templateBasePath)) {
// Base path is empty
- throw new UnexpectedValueException(sprintf('[%s:%d] Variable templateBasePath is empty.', $templateInstance->__toString(), __LINE__), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
+ throw new UnexpectedValueException(sprintf('[%s:%d] Variable templateBasePath is empty.', $templateInstance->__toString(), __LINE__), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
} elseif (!is_dir($templateBasePath)) {
// Is not a path
throw new InvalidDirectoryException(array($templateInstance, $templateBasePath), self::EXCEPTION_INVALID_PATH_NAME);
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
use Org\Mxchange\CoreFramework\Filesystem\InvalidDirectoryException;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
use Org\Mxchange\CoreFramework\Menu\RenderableMenu;
use Org\Mxchange\CoreFramework\Parser\Parseable;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
use Org\Mxchange\CoreFramework\Template\Engine\BaseTemplateEngine;
use Org\Mxchange\CoreFramework\Template\CompileableTemplate;
use Org\Mxchange\CoreFramework\Traits\Stack\StackableTrait;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Is the base path valid?
if (empty($templateBasePath)) {
// Base path is empty
- throw new UnexpectedValueException(sprintf('[%s:%d] Variable templateBasePath is empty.', $templateInstance->__toString(), __LINE__), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
+ throw new UnexpectedValueException(sprintf('[%s:%d] Variable templateBasePath is empty.', $templateInstance->__toString(), __LINE__), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
} elseif (!is_dir($templateBasePath)) {
// Is not a path
throw new InvalidDirectoryException(array($templateInstance, $templateBasePath), self::EXCEPTION_INVALID_PATH_NAME);
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
use Org\Mxchange\CoreFramework\Factory\Template\XmlTemplateEngineFactory;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
use Org\Mxchange\CoreFramework\Template\CompileableTemplate;
use Org\Mxchange\CoreFramework\Template\Engine\BaseTemplateEngine;
use Org\Mxchange\CoreFramework\Template\Xml\CompileableXmlTemplate;
*/
protected function __construct (string $className) {
// Call parent constructor
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-XML-TEMPLATE-ENGINE: className=%s - CONSTRUCTED!', $className));
parent::__construct($className);
+
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-XML-TEMPLATE-ENGINE: EXIT!');
}
/**
* @param $typePrefix Type prefix
* @param $xmlTemplateType Type of XML template
* @return $templateInstance An instance of TemplateEngine
+ * @throws InvalidArgumentException If a parameter has an invalid value
* @throws BasePathIsEmptyException If the provided $templateBasePath is empty
* @throws InvalidBasePathStringException If $templateBasePath is no string
* @throws BasePathIsNoDirectoryException If $templateBasePath is no
* read-protected
*/
protected function initXmlTemplateEngine (string $typePrefix, string $xmlTemplateType) {
+ // Check on parameter
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-XML-TEMPLATE-ENGINE: typePrefix=%s,xmlTemplateType=%s - CALLED!', $typePrefix, $xmlTemplateType));
+ if (empty($typePrefix)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "typePrefix" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($xmlTemplateType)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "xmlTemplateType" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Set XML template type and prefix
$this->xmlTemplateType = $xmlTemplateType;
$this->typePrefix = $typePrefix;
$applicationInstance = ApplicationHelper::getSelfInstance();
// Determine base path
- $templateBasePath = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('application_base_path') . FrameworkBootstrap::getRequestInstance()->getRequestElement('app') . '/';
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-XML-TEMPLATE-ENGINE: applicationInstance=%s', $applicationInstance->__toString()));
+ $templateBasePath = sprintf('%s%s%s',
+ FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('application_base_path'),
+ FrameworkBootstrap::getRequestInstance()->getRequestElement('app'),
+ DIRECTORY_SEPARATOR
+ );
// Is the base path valid?
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-XML-TEMPLATE-ENGINE: templateBasePath=%s', $templateBasePath));
if (empty($templateBasePath)) {
// Base path is empty
throw new BasePathIsEmptyException($this, self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
$this->stackerName = $typePrefix . '_' . $xmlTemplateType;
// Init stacker
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-XML-TEMPLATE-ENGINE: this->stackerName=%s', $this->stackerName));
$stackInstance->initStack($this->stackerName);
// Set it
$this->setStackInstance($stackInstance);
// Set it in main nodes
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-XML-TEMPLATE-ENGINE: Adding xmlTemplateType=%s to this->mainNodes ...', $xmlTemplateType));
array_push($this->mainNodes, str_replace('_', '-', $xmlTemplateType));
+
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-XML-TEMPLATE-ENGINE: EXIT!');
}
/**
*/
public function loadXmlTemplate (string $templateName = '') {
// Is the template name empty?
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-XML-TEMPLATE-ENGINE: templateName=%s - CALLED!', $templateName));
if (empty($templateName)) {
// Set generic template name
$templateName = $this->typePrefix . '_' . $this->xmlTemplateType . '_template_type';
}
// Set template type
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-XML-TEMPLATE-ENGINE: templateName=%s', $templateName));
$this->setTemplateType(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry($templateName));
// Load the special template
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-XML-TEMPLATE-ENGINE: Invoking this->loadTemplate(%s) ...', $this->xmlTemplateType));
$this->loadTemplate($this->xmlTemplateType);
+
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-XML-TEMPLATE-ENGINE: EXIT!');
}
/**
*/
public function readXmlData (string $key) {
// Is key parameter valid?
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-XML-TEMPLATE-ENGINE: key=%s - CALLED!', $key));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-XML-TEMPLATE-ENGINE: key=%s - CALLED!', $key));
if (empty($key)) {
// Throw exception
- throw new InvalidArgumentException('Parameter key is empty');
+ throw new InvalidArgumentException('Parameter key is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
}
// Read the variable
$value = parent::readVariable($key, 'general');
// Is this null?
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-XML-TEMPLATE-ENGINE: value[]=%s', gettype($value)));
if (is_null($value)) {
// Bah, needs fixing.
$this->debugInstance(sprintf('[%s:%d]: key=%s returns NULL', __METHOD__, __LINE__, $key));
}
// Return value
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-XML-TEMPLATE-ENGINE: value[%s]=%s - EXIT!', gettype($value), $value));
return $value;
}
* @param $node The XML node we should load a dependency template
* @param $templateDependency A template to load to satisfy dependencies
* @return void
+ * @throws InvalidArgumentException If a parameter has an invalid value
*/
protected function handleTemplateDependency (string $node, string $templateDependency) {
- // Check that the XML node is not empty
- assert(!empty($node));
+ // Check parameter
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-XML-TEMPLATE-ENGINE: node=%s,templateDependency=%s - CALLED!', $node, $templateDependency));
+ if (empty($node)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "node" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($templateDependency)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "templateDependency" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
// Is the template dependency set?
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-XML-TEMPLATE-ENGINE: node=%s,templateDependency=%s', $node, $templateDependency));
if ((!empty($templateDependency)) && (!isset($this->dependencyContent[$node]))) {
+ // Create class name
+ $configKey = sprintf('%s_%s_%s_template_class', $this->typePrefix, self::convertDashesToUnderscores($node), $this->xmlTemplateType);
+
// Get a temporay template instance
- $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance($this->typePrefix . '_' . self::convertDashesToUnderscores($node) . '_' . $this->xmlTemplateType . '_template_class');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-XML-TEMPLATE-ENGINE: configKey=%s', $configKey));
+ $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance();
// Then load it
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-XML-TEMPLATE-ENGINE: templateInstance=%s', $templateInstance->__toString()));
$templateInstance->loadXmlTemplate($templateDependency);
// Parse the XML content
$templateInstance->renderXmlContent();
// Save the parsed raw content in our dependency array
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-XML-TEMPLATE-ENGINE: Invoking templateInstance->getRawTemplateData() for this->dependencyContent[%s] ...', $node));
$this->dependencyContent[$node] = $templateInstance->getRawTemplateData();
}
+
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-XML-TEMPLATE-ENGINE: EXIT!');
}
/**
* @param $element The element we shall handle
* @param $attributes All attributes
* @return void
+ * @throws InvalidArgumentException If a parameter has an invalid value
* @throws InvalidXmlNodeException If an unknown/invalid XML node name was found
*/
public final function startElement ($resource, string $element, array $attributes) {
+ // Check parameters
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-XML-TEMPLATE-ENGINE: resource[%s]=%s,element=%s,attributes()=%d - CALLED!', gettype($resource), $resource, $element, count($attributes)));
+ if (!is_resource($resource)) {
+ // Throw IAE
+ throw new InvalidArgumentException(sprintf('Parameter resource has unexpected type %s', gettype($resource)), FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($element)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "element" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Initial method name which will never be called...
$methodName = $this->initMethodName;
// Make the element name lower-case
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-XML-TEMPLATE-ENGINE: methodName=%s', $methodName));
$element = strtolower($element);
// Is the element a main node?
- //* DEBUG: */ echo "START: >".$element."<<br />\n";
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-XML-TEMPLATE-ENGINE: element=%s', $element));
if (in_array($element, $this->getMainNodes())) {
// Okay, main node found!
$methodName = 'start' . StringUtils::convertToClassName($element);
}
// Call method
- call_user_func_array(array($this, $methodName), $attributes);
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-XML-TEMPLATE-ENGINE: Invoking this->%s(attributes()=%d) ...', $methodName, count($attributes)));
+ call_user_func_array([$this, $methodName], $attributes);
+
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-XML-TEMPLATE-ENGINE: EXIT!');
}
/**
* @throws XmlNodeMismatchException If current main node mismatches the closing one
*/
public final function finishElement ($resource, string $nodeName) {
+ // Check parameters
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-XML-TEMPLATE-ENGINE: resource[%s]=%s,nodeName=%s - CALLED!', gettype($resource), $resource, $nodeName));
+ if (!is_resource($resource)) {
+ // Throw IAE
+ throw new InvalidArgumentException(sprintf('Parameter resource has unexpected type %s', gettype($resource)), FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($nodeName)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "nodeName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Make all lower-case
$nodeName = strtolower($nodeName);
// Does this match with current main node?
- //* DEBUG: */ echo "END: >".$nodeName."<<br />\n";
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-XML-TEMPLATE-ENGINE: nodeName=%s', $nodeName));
if (($nodeName != $this->getCurrMainNode()) && (in_array($nodeName, $this->getMainNodes()))) {
// Did not match!
- throw new XmlNodeMismatchException (array($this, $nodeName, $this->getCurrMainNode()), XmlParser::EXCEPTION_XML_NODE_MISMATCH);
+ throw new XmlNodeMismatchException ([$this, $nodeName, $this->getCurrMainNode()], XmlParser::EXCEPTION_XML_NODE_MISMATCH);
}
// Construct method name
$methodName = 'finish' . StringUtils::convertToClassName($nodeName);
// Call the corresponding method
- //* DEBUG: */ echo "call: ".$methodName."<br />\n";
- call_user_func_array(array($this, $methodName), array());
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-XML-TEMPLATE-ENGINE: Invoking this->%s() ...', $methodName));
+ call_user_func_array([$this, $methodName], []);
+
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-XML-TEMPLATE-ENGINE: EXIT!');
}
/**
*
* @param $content Valid XML content or if not set the current loaded raw content
* @return void
- * @throws XmlParserException If an XML error was found
+ * @throws InvalidArgumentException If a parameter has an invalid value
*/
public function renderXmlContent (string $content = NULL) {
// Is the content set?
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-XML-TEMPLATE-ENGINE: content[%s]()=%d - CALLED!', gettype($content), strlen($content)));
if (is_null($content)) {
// Get current content
$content = $this->getRawTemplateData();
+ } elseif (empty($content)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "content" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
}
// Get a XmlParser instance
$parserInstance = ObjectFactory::createObjectByConfiguredName('xml_parser_class', [$this]);
// Check if XML compacting is enabled
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-XML-TEMPLATE-ENGINE: parserInstance=%s', $parserInstance->__toString()));
if ($this->isXmlCompactingEnabled()) {
// Yes, so get a decorator class for transparent compacting
- $parserInstance = ObjectFactory::createObjectByConfiguredName('deco_compacting_xml_parser_class', array($parserInstance));
+ $parserInstance = ObjectFactory::createObjectByConfiguredName('deco_compacting_xml_parser_class', [$parserInstance]);
}
// Parse the XML document
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-XML-TEMPLATE-ENGINE: Invoking parserInstance->parseXmlContent(content()=%d) ...', strlen($content)));
$parserInstance->parseXmlContent($content);
+
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-XML-TEMPLATE-ENGINE: EXIT!');
}
/**
use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
use Org\Mxchange\CoreFramework\Filesystem\FileNotFoundException;
use Org\Mxchange\CoreFramework\Generic\FrameworkException;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
use Org\Mxchange\CoreFramework\Socket\InvalidSocketException;
// Import SPL stuff
use \InvalidArgumentException;
use \SplFileInfo;
+use \UnexpectedValueException;
/**
* This class contains static helper functions for console applications
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
/**
* Default is that this class is noisy
*/
- private static $quietResolver = FALSE;
+ private static $isQuietResolver = FALSE;
+
+ /**
+ * Cached values
+ */
+ private static $cache = [];
/**
* Protected constructor
parent::__construct(__CLASS__);
// Cache configuration entry
- self::$quietResolver = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('quiet_dns_resolver');
+ self::$isQuietResolver = FrameworkBootstrap::getConfigurationInstance()->isEnabled('quiet_dns_resolver');
}
/**
*/
protected function isProxyUsed () {
// Do we have cache?
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CONSOLE-TOOLS: CALLED!');
if (!isset($GLOBALS[__METHOD__])) {
// Determine it
$GLOBALS[__METHOD__] = (
}
// Return cache
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CONSOLE-TOOLS: isUsed=%d', $GLOBALS[__METHOD__]));
return $GLOBALS[__METHOD__];
}
*/
protected function setupProxyTunnel (string $host, int $port, $socketResource) {
// Validate parameter
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CONSOLE-TOOLS: host=%s,port=%d,socketResource=%s - CALLED!', $host, $port, $socketResource));
if (empty($host)) {
// Throw IAE
- throw new InvalidArgumentException('Parameter "host" is empty');
+ throw new InvalidArgumentException('Parameter "host" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif ($port < 1) {
// Throw IAE
throw new InvalidArgumentException(sprintf('port=%d is not valid', $port));
// Add last new-line
$proxyTunnel .= self::HTTP_EOL;
- //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONSOLE-TOOLS: proxyTunnel=' . $proxyTunnel);
// Write request
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CONSOLE-TOOLS: Sending %d bytes to socketResource=%s (proxy tunnel) ...', strlen($proxyTunnel), $socketResource));
fwrite($socketResource, $proxyTunnel);
// Got response?
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CONSOLE-TOOLS: feof(%s)=%d', $socketResource, intval(feof($socketResource))));
if (feof($socketResource)) {
// No response received
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CONSOLE-TOOLS: response()=%d, feof! - EXIT!', count($response)));
return $response;
}
}
// All fine!
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CONSOLE-TOOLS: respArray()=%d - EXIT!', count($respArray)));
return $respArray;
}
*/
protected function extractHostnameFromRawData (string $rawData) {
// Validate parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CONSOLE-TOOLS: rawData=%s - CALLED!', $rawData));
if (empty($rawData)) {
// Throw IAE
- throw new InvalidArgumentException('Parameter "rawData" is empty');
+ throw new InvalidArgumentException('Parameter "rawData" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
}
// Default is invalid
$data = explode(PHP_EOL, $rawData);
// "Walk" through it
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CONSOLE-TOOLS: data()=%d', count($data)));
foreach ($data as $line) {
// Trim it
$line = trim($line);
// Begins with a hash (#) = comment?
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CONSOLE-TOOLS: line=%s', $line));
if (substr($line, 0, 1) == '#') {
// Then skip it
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CONSOLE-TOOLS: line=%s - SKIPPED!', $line));
continue;
}
$hostData = explode('=', $line);
// Make sure only a key=value pair goes through
- assert(count($hostData) == 2);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CONSOLE-TOOLS: hostData()=%d', count($hostData)));
+ if (count($hostData) < 2) {
+ // Ops, wrong count
+ throw new UnexpectedValueException(sprintf('hostData()=%d is unexpected, line=%s', count($hostData), $line), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
+ }
// Try to get it and abort
$hostname = str_replace(
['', ''],
$hostData[1]
);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CONSOLE-TOOLS: hostname=%s from hostData - BREAK!', $hostname));
break;
} else {
// Use it directly
$hostname = $line;
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CONSOLE-TOOLS: hostname=%s from line - BREAK!', $line));
break;
}
}
// Return it
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CONSOLE-TOOLS: hostname=%s - EXIT!', $hostname));
return $hostname;
}
*/
public static function resolveIpAddress (string $hostname) {
// Validate parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CONSOLE-TOOLS: hostname=%s - CALLED!', $hostname));
if (empty($hostname)) {
// Throw IAE
- throw new InvalidArgumentException('Parameter "hostname" is empty');
- } elseif (self::$quietResolver !== TRUE) {
+ throw new InvalidArgumentException('Parameter "hostname" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (self::$isQuietResolver !== TRUE) {
// Debug message
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:] Host name to resolve is: %s',
+ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('[%s:] Host name to resolve is: %s',
__CLASS__,
$hostname
));
// Resolve it
// @TODO Here should the cacher be implemented
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CONSOLE-TOOLS: hostname=%s', $hostname));
$ipResolved = gethostbyname($hostname);
// Was it fine?
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CONSOLE-TOOLS: ipResolved[%s]=%s', gettype($ipResolved), $ipResolved));
if (($ipResolved !== false) && ($ipResolved != $hostname)) {
// Okay, this works!
$ipAddress = $ipResolved;
// Quiet?
- if (self::$quietResolver !== TRUE) {
+ if (self::$isQuietResolver !== TRUE) {
// Debug message
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:] Resolved IP address is: %s',
+ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('[%s:] Resolved IP address is: %s',
__CLASS__,
$ipAddress
));
}
} else {
// Problem while resolving IP address
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:] Problem resolving IP address for host %s. Please check your /etc/hosts file.',
+ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('[%s:] Problem resolving IP address for host %s. Please check your /etc/hosts file.',
__CLASS__,
$hostname
));
}
// Return resolved IP
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CONSOLE-TOOLS: ipAddress=%s - EXIT!', $ipAddress));
return $ipAddress;
}
/**
- * Aquires the IP address of this host by reading the /etc/hostname file
- * and solving it. It is now stored in configuration
+ * acquires this host's LAN name. It tries a varity of different source.
*
- * @return $ipAddress Aquired IPv4 address
+ * @return $hostName The acquired name of this host or something invalid
*/
- public static function acquireSelfIpAddress () {
- // Local IP by default
- $ipAddress = '127.0.0.1';
+ public static function acquireHostname () {
+ // Is cache there?
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CONSOLE-TOOLS: CALLED!');
+ if (!isset(self::$cache[__METHOD__])) {
+ // Get a new instance
+ $toolsInstance = new ConsoleTools();
- // Get a new instance
- $helperInstance = new ConsoleTools();
+ // Get SplFileInfo instance
+ $infoInstance = new SplFileInfo(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('hostname_file'));
- // Get SplFileInfo instance
- $infoInstance = new SplFileInfo(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('hostname_file'));
+ // Init host name
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CONSOLE-TOOLS: infoInstance=%s', $infoInstance->__toString()));
+ $hostname = 'host.invalid';
- try {
- // Get a file pointer
- $fileInstance = ObjectFactory::createObjectByConfiguredName('file_raw_input_class', array($infoInstance));
+ // Try to check /etc/hostname first
+ try {
+ // Get a file pointer
+ $fileInstance = ObjectFactory::createObjectByConfiguredName('file_raw_input_class', [$infoInstance]);
- // Read the file
- $rawData = trim($fileInstance->readFromFile());
+ // Read the file
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CONSOLE-TOOLS: fileInstance=%s', $fileInstance->__toString()));
+ $rawData = trim($fileInstance->readFromFile());
- // Close the file
- $fileInstance->closeFile();
+ // Close the file
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CONSOLE-TOOLS: rawData=%s', $rawData));
+ $fileInstance->closeFile();
- // Extract hostname from it
- $hostname = $helperInstance->extractHostnameFromRawData($rawData);
+ // Extract hostname from it
+ $hostname = $toolsInstance->extractHostnameFromRawData($rawData);
- // Resolve the IP number
- $ipAddress = self::resolveIpAddress($hostname);
- } catch (FileNotFoundException $e) {
- // Fall-back to 'SESSION_SVR' which found on my Sun Station
- if (isset($_SERVER['SESSION_SVR'])) {
- // Resolve it
- $ipAddress = self::resolveIpAddress($_SERVER['SESSION_SVR']);
- } elseif (isset($_SERVER['COMPUTERNAME'])) {
- // May happen on some Windows XP systems, so also try this
- $ipAddress = self::resolveIpAddress($_SERVER['COMPUTERNAME']);
- } else {
- // Could not find our hostname
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:] WARNING: Cannot resolve my own IP address.',
- $helperInstance->__toString()
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CONSOLE-TOOLS: hostname=%s from /etc/hostname', $hostname));
+ } catch (FileNotFoundException $e) {
+ // Fall-back to 'SESSION_SVR' which found on my Sun Station
+ if (isset($_SERVER['SESSION_SVR'])) {
+ // Resolve it
+ $hostname = $_SERVER['SESSION_SVR'];
+ } elseif (isset($_SERVER['COMPUTERNAME'])) {
+ // May happen on some Windows XP systems, so also try this
+ $hostname = $_SERVER['COMPUTERNAME'];
+ } else {
+ // Could not find our hostname
+ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('[%s:] WARNING: Cannot acquire my own host name.',
+ $toolsInstance->__toString()
+ ));
+ }
+
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CONSOLE-TOOLS: hostname=%s from _SERVER array', $hostname));
+ } catch (FrameworkException $e) {
+ // Output debug message
+ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('[%s:] Problem while resolving own IP address: [%s|%s]:%s',
+ $toolsInstance->__toString(),
+ $e->__toString(),
+ $e->getHexCode(),
+ $e->getMessage()
));
}
- } catch (FrameworkException $e) {
- // Output debug message
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:] Problem while resolving own IP address: [%s|%s]:%s',
- $helperInstance->__toString(),
- $e->__toString(),
- $e->getHexCode(),
- $e->getMessage()
- ));
+
+ // Set cache
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CONSOLE-TOOLS: Setting hostname=%s ...', $hostname));
+ self::$cache[__METHOD__] = $hostname;
+ } else {
+ // Get from cache
+ $hostname = self::$cache[__METHOD__];
+ }
+
+ // Return it
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CONSOLE-TOOLS: hostname=%s - EXIT!', $hostname));
+ return $hostname;
+ }
+
+ /**
+ * acquires the IP address of this host by reading the /etc/hostname file
+ * and solving it. It is now stored in configuration
+ *
+ * @return $ipAddress acquired IPv4 address
+ */
+ public static function acquireSelfIpAddress () {
+ // Is cache there?
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CONSOLE-TOOLS: CALLED!');
+ if (!isset(self::$cache[__METHOD__])) {
+ // Get host name
+ $hostname = self::acquireHostname();
+
+ // Resolve the IP number
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CONSOLE-TOOLS: hostname=%s', $hostname));
+ $ipAddress = self::resolveIpAddress($hostname);
+
+ // Set cache
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CONSOLE-TOOLS: Setting ipAddress=%s ...', $ipAddress));
+ self::$cache[__METHOD__] = $ipAddress;
+ } else {
+ // Get it from cache
+ $ipAddress = self::$cache[__METHOD__];
}
// Return it
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CONSOLE-TOOLS: ipAddress=%s - EXIT!', $ipAddress));
return $ipAddress;
}
*/
public static function determineExternalAddress () {
// Get helper instance
- $helperInstance = new ConsoleTools();
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CONSOLE-TOOLS: CALLED!');
+ $toolsInstance = new ConsoleTools();
// First get a socket
// @TODO Add some DNS caching here
// Open connection
- if ($helperInstance->isProxyUsed() === true) {
+ if ($toolsInstance->isProxyUsed() === true) {
// Resolve hostname into IP address
$ipAddress = self::resolveIpAddress(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('proxy_host'));
// Connect to host through proxy connection
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CONSOLE-TOOLS: ipAddress=%s', $ipAddress));
$socketResource = fsockopen($ipAddress, FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('proxy_port'), $errorNo, $errorStr, 30);
} else {
// Connect to host directly
}
// Check if there was an error else
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CONSOLE-TOOLS: socketResource[%s]=%s,errorNo=%d,errorStr=%s', gettype($socketResource), $socketResource, $errorNo, $errorStr));
if ($errorNo > 0) {
// Then throw again
- throw new InvalidSocketException(array($helperInstance, $socketResource, $errorNo, $errorStr), BaseFrameworkSystem::EXCEPTION_INVALID_SOCKET);
+ throw new InvalidSocketException([$toolsInstance, $socketResource, $errorNo, $errorStr], BaseFrameworkSystem::EXCEPTION_INVALID_SOCKET);
}
// Prepare the GET request
- $request = 'GET ' . ($helperInstance->isProxyUsed() === true ? 'http://shipsimu.org' : '') . '/ip.php HTTP/1.0' . self::HTTP_EOL;
+ $request = 'GET ' . ($toolsInstance->isProxyUsed() === true ? 'http://shipsimu.org' : '') . '/ip.php HTTP/1.0' . self::HTTP_EOL;
$request .= 'Host: shipsimu.org' . self::HTTP_EOL;
$request .= 'User-Agent: ' . self::HTTP_USER_AGENT . self::HTTP_EOL;
$request .= 'Connection: close' . self::HTTP_EOL;
// Do we use proxy?
- if ($helperInstance->isProxyUsed() === true) {
+ if ($toolsInstance->isProxyUsed() === true) {
// CONNECT method?
- if (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('proxy_connect_method') == 'Y') {
+ if (FrameworkBootstrap::getConfigurationInstance()->isEnabled('proxy_connect_method')) {
// Setup proxy tunnel
- $response = $helperInstance->setupProxyTunnel('shipsimu.org', 80, $socketResource);
+ $response = $toolsInstance->setupProxyTunnel('shipsimu.org', 80, $socketResource);
// If the response is invalid, abort
if ((count($response) == 3) && (empty($response[0])) && (empty($response[1])) && (empty($response[2]))) {
// Invalid response!
- $helperInstance->debugBackTrace('Proxy tunnel not working: response=' . print_r($response, true));
+ $toolsInstance->debugBackTrace('Proxy tunnel not working: response=' . print_r($response, true));
}
} else {
// Add header for proxy
$request .= self::HTTP_EOL;
// Send it to the socket
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CONSOLE-TOOLS: Writing %d bytes to socketResource=%s ...', strlen($request), $socketResource));
fwrite($socketResource, $request);
// Init IP (this will always be the last line)
// And read the reply
while (!feof($socketResource)) {
// Get line
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CONSOLE-TOOLS: feof()=%d', intval(feof($socketResource))));
$externalAddress = trim(fgets($socketResource, 128));
// Detect HTTP response
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CONSOLE-TOOLS: externalAddress=%s', $externalAddress));
if ((substr($externalAddress, 0, 7) == 'HTTP/1.') && (substr($externalAddress, -6, 6) != '200 OK')) {
// Stop processing
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('CONSOLE-TOOLS: BREAK!');
break;
}
}
fclose($socketResource);
// Return determined external address
- /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONSOLE-TOOLS: Resolved external address: ' . $externalAddress);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CONSOLE-TOOLS: externalAddress=%s - EXIT!', $externalAddress));
return $externalAddress;
}
*/
public static function analyzeEnvironmentForType () {
// Default is the console
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CONSOLE-TOOLS: CALLED!');
$type = 'console';
// Now, do we have a request method, or query string set?
}
// Return it
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CONSOLE-TOOLS: type=%s - EXIT!', $type));
return $type;
}
*/
public static function analyzeEnvironmentForClassType () {
// Default is the console
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CONSOLE-TOOLS: CALLED!');
$type = 'console';
// Now, do we have a request method, or query string set?
}
// Return it
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CONSOLE-TOOLS: type=%s - EXIT!', $type));
return $type;
}
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
$frontendInstance = ObjectFactory::createObjectByConfiguredName('user_db_frontend_class');
// Get the primary key back from the frontend
- $primaryKey = $frontendInstance->getPrimaryKeyValue();
+ $primaryKey = $frontendInstance->generatePrimaryKey();
// Get that field
$primaryValue = $this->getField($primaryKey);
namespace Org\Mxchange\CoreFramework\User\Guest;
// Import framework stuff
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Manager\Guest\ManageableGuest;
use Org\Mxchange\CoreFramework\Registry\Registerable;
use Org\Mxchange\CoreFramework\Request\Requestable;
use Org\Mxchange\CoreFramework\User\BaseUser;
use Org\Mxchange\CoreFramework\User\UsernameMissingException;
+// Import SPL stuff
+use \InvalidArgumentException;
+
/**
* A generic class for handling guests
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
* @throws UsernameMissingException If the username does not exist
* @throws UserNoGuestException If the user is no guest account
*/
- public static final function createGuestByUsername ($userName) {
+ public static final function createGuestByUsername (string $userName) {
+ // Check parameter
+ if (empty($userName)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Paramter "userName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Get a new instance
$userInstance = new Guest();
* @param $email Email address of the user
* @return $userInstance An instance of this user class
*/
- public static final function createGuestByEmail ($email) {
+ public static final function createGuestByEmail (string $email) {
+ // Check parameter
+ if (empty($email)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Paramter "email" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Get a new instance
$userInstance = new Guest();
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
use Org\Mxchange\CoreFramework\Database\Frontend\User\UserDatabaseFrontend;
use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Manager\Login\ManageableMember;
use Org\Mxchange\CoreFramework\Registry\Registerable;
use Org\Mxchange\CoreFramework\User\BaseUser;
use Org\Mxchange\CoreFramework\User\UsernameMissingException;
+// Import SPL stuff
+use \InvalidArgumentException;
+
/**
* A generic class for handling users
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
* @throws UsernameMissingException If the username does not exist
* @throws UnexpectedGuestAccountException If the user status is 'guest'
*/
- public static final function createMemberByUsername ($userName) {
+ public static final function createMemberByUsername (string $userName) {
+ // Check parameter
+ if (empty($userName)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "userName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Get a new instance
$userInstance = new Member();
* @param $email Email address of the user
* @return $userInstance An instance of this user class
*/
- public static final function createMemberByEmail ($email) {
+ public static final function createMemberByEmail (string $email) {
+ // Check parameter
+ if (empty($email)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "email" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Get a new instance
$userInstance = new Member();
// Import framework stuff
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
// Import SPL stuff
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
*/
public static function mapNumericKeysToAssociative (array $numericArray, array $mapping) {
// Validate parameters
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('ARRAY-UTILS: numericArray()=%d,mapping()=%d - CALLED!', count($numericArray), count($mapping)));
if (count($numericArray) == 0) {
// Throw IAE
- throw new InvalidArgumentException('Array "numericArray" is empty');
+ throw new InvalidArgumentException('Array "numericArray" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif (count($mapping) == 0) {
// Throw it again
- throw new InvalidArgumentException('Array "mapping" is empty');
+ throw new InvalidArgumentException('Array "mapping" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif (count($numericArray) != count($mapping)) {
// Throw it yet again
throw new InvalidArgumentException(sprintf('numericArray()=%d does not match mapping()=%d', count($numericArray), count($mapping)));
// "Walk" over the mapping array
foreach ($mapping as $sourceIndex => $targetName) {
// Is the source index not there?
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('ARRAY-UTILS: sourceIndex=%d,targetName=%s', $sourceIndex, $targetName));
if (!array_key_exists($sourceIndex, $numericArray)) {
// Should always be there!
- throw new OutOfBoundsException(sprintf('numericArray[%d] does not exist.', $sourceIndex));
+ throw new OutOfBoundsException(sprintf('numericArray[%d] does not exist.', $sourceIndex), FrameworkInterface::EXCEPTION_OUT_OF_BOUNDS);
}
// "Map" (copy) it to new array
}
// Return fully mapped array
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('ARRAY-UTILS: mappedArray()=%d - EXIT!', count($mappedArray)));
return $mappedArray;
}
// Import framework stuff
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
// Import SPL stuff
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*/
private static function staticInitializer () {
// Is $hashFunction set?
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CRYPRO-UTILS: self::hashFunction[]=%s - CALLED!', gettype(self::$hashFunction)));
if (empty(self::$hashFunction)) {
// Get instance
$dummyInstance = new CryptoUtils();
// Set hash function from configuration
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('CRYPRO-UTILS: Setting self::hashFunction from configuration entry ...');
self::$hashFunction = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('crypto_hash_function_name');
}
+
+ // Trace message
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CRYPRO-UTILS: EXIT!');
}
/**
*/
public static final function hash (string $str) {
// Validate parameter/mhash extension
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CRYPTO-UTILS: str=%s - CALLED!', $str));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CRYPTO-UTILS: str=%s - CALLED!', $str));
if (empty($str)) {
// Throw IAE
- throw new InvalidArgumentException('Parameter "str" is empty');
+ throw new InvalidArgumentException('Parameter "str" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif (!extension_loaded('hash')) {
// Should be there
- throw new LogicException('Extension ext-hash not loaded');
+ throw new LogicException('Extension ext-hash not loaded', FrameworkInterface::EXCEPTION_LOGIC_EXCEPTION);
}
// Invoke static initializer
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CRYPRO-UTILS: Invoking self::staticInitializier() ...');
self::staticInitializer();
// Hash given string with (better secure) hasher
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CRYPRO-UTILS: Invoking hash(self::%s,%s,true) ...', $hashFunction, $str));
$hash = hash(self::$hashFunction, $str, true);
// Return it
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CRYPTO-UTILS: hash{}=0x%s - EXIT!', bin2hex($hash)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CRYPTO-UTILS: hash{}=0x%s - EXIT!', bin2hex($hash)));
return $hash;
}
*/
public static final function getHashLength () {
// Invoke static initializer
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CRYPRO-UTILS: Invoking self::staticInitializer() ... - CALLED!');
self::staticInitializer();
// Is it cashed?
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('CRYPRO-UTILS: self::hashLength[%s]=%d', gettype(self::$hashLength), self::$hashLength));
if (is_null(self::$hashLength)) {
// No, then hash a string and save its length.
self::$hashLength = strlen(self::hash('abc123'));
}
// Return it
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CRYPRO-UTILS: self::hashLength=%d - EXIT!', self::$hashLength));
return self::$hashLength;
}
// Import framework stuff
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
+// Import SPL stuff
+use \InvalidArgumentException;
+
/**
* A number utility class
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
/**
* Filter a given number into a localized number
*
- * @param $value The raw value from e.g. database
+ * @param $value The raw float value from e.g. database
* @return $localized Localized value
+ * @throws InvalidArgumentException If a parameter has an invalid value
*/
- public static function doFilterFormatNumber ($value) {
+ public static function doFilterFormatNumber (float $value) {
+ // Check value
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('NUMBER-UTILS: value=%s - CALLED!', $value));
+ if ($value < 0) {
+ // Not valid value
+ throw new InvalidArgumentException(sprintf('value=%s cannot be below zero', $value));
+ }
+
// Generate it from config and localize dependencies
switch (FrameworkBootstrap::getLanguageInstance()->getLanguageCode()) {
case 'de': // German format is a bit different to default
}
// Return it
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('NUMBER-UTILS: localized=%s - CALLED!', $localized));
return $localized;
}
*
* @param $timestamp Timestamp to prepare (filter) for display
* @return $readable A readable timestamp
+ * @throws InvalidArgumentException If a parameter has an invalid value
*/
- public static function doFilterFormatTimestamp ($timestamp) {
+ public static function doFilterFormatTimestamp (string $timestamp = NULL) {
+ // Check parameter
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('NUMBER-UTILS: timestamp[%s]=%s - CALLED!', gettype($timestamp), $timestamp));
+ if (empty($timestamp)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "timestamp" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Default value to return
$readable = '???';
}
// Return the stamp
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('NUMBER-UTILS: readable=%s - EXIT!', $readable));
return $readable;
}
* @param $castValue Whether to cast the value to double. Do only use this to secure numbers from Requestable classes.
* @param $assertMismatch Whether to assert mismatches
* @return $formatted The (hopefully) secured numbered value
+ * @throws InvalidArgumentException If a parameter has an invalid value
*/
public static function bigintval (string $num, bool $castValue = true, bool $assertMismatch = false) {
+ // Check parameter
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('NUMBER-UTILS: num=%s,castValue=%d,assertMismatch=%d - CALLED!', $num, intval($castValue), intval($assertMismatch)));
+ if ($num === '') {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "num" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Filter all numbers out
$formatted = preg_replace('/[^0123456789]/', '', $num);
// Shall we cast?
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('NUMBER-UTILS: formatted=%s', $formatted));
if ($castValue === true) {
// Cast to biggest numeric type, int is not enough for this cast
$formatted = (double) $formatted;
}
// Assert only if requested
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('NUMBER-UTILS: formatted[%s]=%s', gettype($formatted), $formatted));
if ($assertMismatch === true) {
// Has the whole value changed?
assert(('' . $formatted . '' != '' . $num . '') && (!is_null($num)));
}
// Return result
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('NUMBER-UTILS: formatted[%s]=%s - EXIT!', gettype($formatted), $formatted));
return $formatted;
}
// Import framework stuff
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
use Org\Mxchange\CoreFramework\Configuration\FrameworkConfiguration;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Generic\NullPointerException;
use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
*/
private function __construct () {
// Call parent constructor
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('STRING-UTILS: CONSTRUCTED!');
parent::__construct(__CLASS__);
// Is one not set?
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('STRING-UTILS: self::archArrayElement=%d', self::$archArrayElement));
if (empty(self::$archArrayElement)) {
// Set array element
self::$archArrayElement = (PHP_INT_SIZE === 8 ? 64 : 32);
self::$thousands = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('thousands_separator');
self::$decimals = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('decimals_separator');
}
+
+ // Trace message
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('STRING-UTILS: EXIT!');
}
/**
*/
public static function convertDashesToUnderscores (string $str) {
// Validate parameter
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('STRING-UTILS: str=%s - CALLED!', $str));
if (empty($str)) {
// Entry is empty
- throw new InvalidArgumentException('Parameter "str" is empty');
+ throw new InvalidArgumentException('Parameter "str" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
}
// Convert them all
$str = str_replace('-', '_', $str);
// Return converted string
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('STRING-UTILS: str=%s - EXIT!', $str));
return $str;
}
*/
public static function encodeData ($rawData) {
// Make sure no objects or resources pass through
- //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('STRING-UTILS: rawData[]=%s - CALLED!', gettype($rawData)));
+ //* N NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('STRING-UTILS: rawData[]=%s - CALLED!', gettype($rawData)));
if (is_object($rawData) || is_resource($rawData)) {
// Not all variable types should be serialized here
throw new InvalidArgumentException(sprintf('rawData[]=%s cannot be serialized.', gettype($rawData)));
$encoded = self::packString(json_encode($rawData));
// And return it
- //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('STRING-UTILS: encoded()=%d - EXIT!', strlen($encoded)));
+ //* N NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('STRING-UTILS: encoded()=%d - EXIT!', strlen($encoded)));
return $encoded;
}
*/
public static final function convertToClassName (string $str) {
// Is the parameter valid?
- //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('STRING-UTILS: str=%s - CALLED!', $str));
+ //* N NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('STRING-UTILS: str=%s - CALLED!', $str));
if (empty($str)) {
// No empty strings, please
- throw new InvalidArgumentException('Parameter "str" is empty', self::EXCEPTION_CONFIG_KEY_IS_EMPTY);
+ throw new InvalidArgumentException('Parameter "str" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif (!isset(self::$cache[$str])) {
// Init class name
$className = '';
$str = self::convertDashesToUnderscores($str);
// Now use that underscores to get classname parts for hungarian style
- //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('STRING-UTILS: str=%s - AFTER!', $str));
+ //* N NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('STRING-UTILS: str=%s - AFTER!', $str));
foreach (explode('_', $str) as $strPart) {
// Make the class name part lower case and first upper case
$className .= ucfirst(strtolower($strPart));
}
// Set cache
- //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('STRING-UTILS: self[%s]=%s - SET!', $str, $className));
+ //* N NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('STRING-UTILS: self[%s]=%s - SET!', $str, $className));
self::$cache[$str] = $className;
}
// Return class name
- //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('STRING-UTILS: self[%s]=%s - EXIT!', $str, $className));
+ //* N NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('STRING-UTILS: self[%s]=%s - EXIT!', $str, $className));
return self::$cache[$str];
}
*/
public static function formatCurrency (float $value, string $currency = '€', int $decNum = 2) {
// Init instance
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('STRING-UTILS: value=%s,currency=%s,decNum=%d - CALLED!', $value, $currency, $decNum));
$dummyInstance = new StringUtils();
// Reformat the US number
$price = number_format($value, $decNum, self::$decimals, self::$thousands) . $currency;
// Return as string...
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('STRING-UTILS: price=%s - EXIT!', $price));
return $price;
}
*
* @param $hex Hexadecimal string
* @return $dec Decimal number
+ * @throws InvalidArgumentException If a paramter is invalid
*/
public static function hex2dec (string $hex) {
+ // Check parameter
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('STRING-UTILS: hex=%s - CALLED!', $hex));
+ if (empty($hex)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "hex" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Convert to all lower-case
$hex = strtolower($hex);
}
// Return the decimal number
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('STRING-UTILS: sign=%s,dec=%s - EXIT!', $sign, $dec));
return $sign . $dec;
}
* @param $dec Decimal number, even with negative sign
* @param $maxLength Optional maximum length of the string
* @return $hex Hexadecimal string
+ * @throws InvalidArgumentException If a paramter is invalid
*/
- public static function dec2hex (string $dec, int $maxLength = 0) {
- // maxLength can be zero or devideable by 2
- assert(($maxLength == 0) || (($maxLength % 2) == 0));
+ public static function dec2hex (int $dec, int $maxLength = 0) {
+ // Check parameter
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('STRING-UTILS: dec=%d,maxLength=%d - CALLED!', $dec, $maxLength));
+ if ($dec < 0) {
+ // Throw IAE
+ throw new InvalidArgumentException(sprintf('dec=%d is below zero', $dec));
+ } elseif ($maxLength != 0 && ($maxLength % 2) != 0) {
+ // Throw it again
+ throw new InvalidArgumentException(sprintf('maxLength=%d is not dividable by 2 or zero', $maxLength));
+ }
// Detect sign (negative/positive numbers)
$sign = '';
}
// Return the hexadecimal string
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('STRING-UTILS: sign=%s,hex=%s - EXIT!', $sign, $hex));
return $sign . $hex;
}
*
* @param $asc The ASCII string to be converted
* @return $dec Decimal number
+ * @throws InvalidArgumentException If a paramter is invalid
*/
public static function asc2dec (string $asc) {
+ // Check parameter
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('STRING-UTILS: asc=%s - CALLED!', $asc));
+ if (empty($asc)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "asc" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Convert it into a hexadecimal number
$hex = bin2hex($asc);
// And back into a decimal number
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('STRING-UTILS: hex=%s', $hex));
$dec = self::hex2dec($hex);
// Return it
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('STRING-UTILS: dec=%d - EXIT!', $dec));
return $dec;
}
*
* @param $dec Decimal number
* @return $asc An ASCII string
+ * @throws InvalidArgumentException If a paramter is invalid
*/
- public static function dec2asc (string $dec) {
+ public static function dec2asc (int $dec) {
+ // Check parameter
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('STRING-UTILS: dec=%d - CALLED!', $dec));
+ if ($dec < 0) {
+ // Throw IAE
+ throw new InvalidArgumentException(sprintf('dec=%d is below zero', $dec));
+ }
+
// First convert the number into a hexadecimal string
$hex = self::dec2hex($dec);
// Then convert it into the ASCII string
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('STRING-UTILS: hex=%s', $hex));
$asc = self::hex2asc($hex);
// Return it
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('STRING-UTILS: asc=%s - EXIT!', $asc));
return $asc;
}
*
* @param $hex Hexadecimal string
* @return $asc An ASCII string
+ * @throws InvalidArgumentException If a paramter is invalid
*/
- public static function hex2asc ($hex) {
+ public static function hex2asc (string $hex) {
// Check for length, it must be devideable by 2
- //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('hex='.$hex);
- assert((strlen($hex) % 2) == 0);
+ /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('STRING-UTILS: hex=%s - CALLED!', $hex));
+ if (empty($hex)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "hex" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif ((strlen($hex) % 2) != 0) {
+ // Throw it again
+ throw new InvalidArgumentException(sprintf('hex=%s length not dividable by 2', $hex));
+ }
// Walk the string
$asc = '';
}
// Return the final string
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('STRING-UTILS: asc=%s - EXIT!', $asc));
return $asc;
}
*
* @param $str Unpacked string
* @return $packed Packed string
+ * @throws InvalidArgumentException If a paramter is invalid
* @todo Improve documentation
*/
private static function packString (string $str) {
+ // Check parameter
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('STRING-UTILS: str=%s - CALLED!', $str));
+ if (empty($str)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "str" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// First compress the string (gzcompress is okay)
- //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('STRING-UTILS: str=%s - CALLED!', $str));
$str = gzcompress($str);
// Init variable
$packed = '';
// And start the "encoding" loop
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('STRING-UTILS: Looping through str()=%d ...', strlen($str)));
for ($idx = 0; $idx < strlen($str); $idx += self::$packingData[self::$archArrayElement]['step']) {
$big = 0;
for ($i = 0; $i < self::$packingData[self::$archArrayElement]['step']; $i++) {
// Create chunk
$chunk = str_pad(pack(self::$packingData[self::$archArrayElement]['format'], $l, $r), 8, '0', STR_PAD_LEFT);
- //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('STRING-UTILS: big=%d,chunk(%d)=%s', $big, strlen($chunk), md5($chunk)));
+ //* N NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('STRING-UTILS: big=%d,chunk(%d)=%s', $big, strlen($chunk), md5($chunk)));
$packed .= $chunk;
}
// Return it
- //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('STRING-UTILS: packed=%s - EXIT!', $packed));
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('STRING-UTILS: packed=%s - EXIT!', $packed));
return $packed;
}
* @param $num A string consisting only chars between 0 and 9
* @param $assertMismatch Whether to assert mismatches
* @return $ret The (hopefully) secured hext-numbered value
+ * @throws InvalidArgumentException If a paramter is invalid
*/
public static function hexval (string $num, bool $assertMismatch = false) {
+ // Check parameter
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('STRING-UTILS: num=%s,assertMismatch=%d - CALLED!', $num, intval($assertMismatch)));
+ if (empty($num)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "num" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Filter all numbers out
$ret = preg_replace('/[^0123456789abcdefABCDEF]/', '', $num);
// Assert only if requested
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('STRING-UTILS: ret=%s', $ret));
if ($assertMismatch === true) {
// Has the whole value changed?
assert(('' . $ret . '' != '' . $num . '') && (!is_null($num)));
}
// Return result
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('STRING-UTILS: ret=%s - EXIT!', $ret));
return $ret;
}
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @deprecated Don't use this anymore
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @deprecated Don't use this anymore
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @todo Rename to CompressorMismatchException
<?php
-// Own namespace
-namespace Org\Mxchange\CoreFramework\Configuration;
-
-// Import framework stuff
-use Org\Mxchange\CoreFramework\Generic\FrameworkException;
-
-/**
- * Thrown when the value variable type is NULL, an array, an object or a
- * resource as these values shall not be set as configuration values. Please use
- * FrameworkArrayObject instead!
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.ship-simu.org
- * @todo These are invalid argument exceptions
- *
- * 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 ConfigValueTypeUnsupportedException extends FrameworkException {
- /**
- * The super constructor for all exceptions
- *
- * @param $message Message data array
- * @param $code Error code
- * @return void
- */
- public function __construct (array $messageArray, int $code) {
- // Construct message
- $message = sprintf('[%s:%d] Configuration key %s has unspported value type %s.',
- $messageArray[0]->__toString(),
- $this->getLine(),
- $messageArray[1],
- gettype($messageArray[2])
- );
-
- // Call parent exception constructor
- parent::__construct($message, $code);
- }
-
-}
+// @DEPRECATED
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @todo Rename this class to NoFoundEntryException
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @deprecated Don't use this anymore
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @deprecated Don't use this anymore
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @deprecated Don't use this
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @deprecated Please don't use this
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @deprecated Please don't use this
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @deprecated Don't use this anymore
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @deprecated Don't use this anymore
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @deprecated Don't use this anymore
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @deprecated Don't use this anymore
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
<?php
-// Own namespace
-namespace Org\Mxchange\CoreFramework\Chain\Filter;
-
-// Import framework stuff
-use Org\Mxchange\CoreFramework\Generic\FrameworkException;
-
-/**
- * An exception thrown in a filter chain to stop processing further filters
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 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 InvalidFilterChainException extends FrameworkException {
- /**
- * The super constructor for all exceptions
- *
- * @param $filterInstance Instance of a filter class
- * @param $code Exception code for better debugging
- * @return void
- */
- public function __construct (array $filterArray, int $code) {
- // Construct the message
- $message = sprintf('[%s:%d] Filter chain %s is not initialized.',
- $filterArray[0]->__toString(),
- $this->getLine(),
- $filterArray[1]
- );
-
- // Call the parent exception
- parent::__construct($message, $code);
- }
-
-}
+// @DEPRECATED
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @deprecated Don't use this anymore
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @deprecated Don't use this anymore
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @deprecated Don't use this anymore
<?php
-// Own namespace
-namespace Org\Mxchange\CoreFramework\Deprecated;
-
-// Import framework stuff
-use Org\Mxchange\CoreFramework\Generic\FrameworkException;
-
-/**
- * An exception thrown when a group was added twice
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 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 HelperGroupAlreadyCreatedException extends FrameworkException {
- /**
- * The constructor
- *
- * @param $messageArray Array containing exception data
- * @param $code Code number for the exception
- * @return void
- */
- public function __construct (array $messageArray, int $code) {
- // Add a message around the missing class
- $message = sprintf('[%s:%d] Group %s already opened before.',
- $messageArray[0]->__toString(),
- $this->getLine(),
- $messageArray[1]
- );
-
- // Call parent constructor
- parent::__construct($message, $code);
- }
-
-}
+// @DEPRECATED
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @deprecated Don't use this anymore
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @deprecated Don't use this anymore
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @deprecated Don't use this anymore
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @deprecated Don't use this anymore
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @deprecated Don't use this anymore
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @deprecated Please don't use this anymore
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @deprecated Don't use this anymore
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @deprecated Don't use this anymore
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @todo Those are logic exceptions and should be rewritten
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @deprecated Don't use this anymore
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @deprecated Don't use this anymore
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @deprecated Don't use this anymore
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @todo Better rename this
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
* An interface for managing applications. This can be a lot. E.g.:
*
* - Un-/locking applications
- * - Creating selectors for the selector-mode
* - Usage statistics
* - And many more...
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
>>>>>>> Some updates::inc/main/interfaces/auth/class_Authorizeable.php
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @todo Find a better name for this interface
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
interface FrameworkInterface {
+ // Exception constants
+ const EXCEPTION_INVALID_ARGUMENT = 0x200;
+ const EXCEPTION_LOGIC_EXCEPTION = 0x201;
+ const EXCEPTION_UNSPPORTED_OPERATION = 0x202;
+ const EXCEPTION_UNEXPECTED_VALUE = 0x203;
+ const EXCEPTION_CLASS_NOT_FOUND = 0x204;
+ const EXCEPTION_BAD_METHOD_CALL = 0x205;
+ const EXCEPTION_OUT_OF_BOUNDS = 0x206;
+ const EXCEPTION_IS_NULL_POINTER = 0x207;
+
/**
* Getter for field name
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
interface Criteria extends FrameworkInterface {
+ // Criteria types
+ const CRITERIA_TYPE_DEFAULT = 'default';
+ const CRITERIA_TYPE_CHOICE = 'choice';
+ const CRITERIA_TYPE_EXCLUDE = 'exclude';
+
/**
* Setter for frontend class name
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
function doSelectCountByCriteria (Criteria $criteriaInstance, array $onlyKeys = []);
/**
- * Getter for primary key used in wrapped table
+ * Generates primary key for this database frontend
*
* @return $primaryKey Primary key used in wrapped table
*/
- function getPrimaryKeyValue ();
+ function generatePrimaryKey ();
/**
* Counts total rows of this table
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Import framework stuff
use Org\Mxchange\CoreFramework\Criteria\Criteria;
use Org\Mxchange\CoreFramework\Criteria\Storing\StoreableCriteria;
-use Org\Mxchange\CoreFramework\Database\Backend\DatabaseBackend;
use Org\Mxchange\CoreFramework\Database\FrameworkDatabase;
/**
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*/
function getConnectionData ();
- /**
- * Setter for the real database layer
- * @param $dbLayer An instance of the real database layer
- * @return void
- */
- function setDatabaseLayer (DatabaseBackend $dbLayer);
-
/**
* Getter for index key
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @todo HandleableDataSet looks strange here
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
--- /dev/null
+<?php
+// Own namespace
+namespace Org\Mxchange\CoreFramework\Logging;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
+
+/**
+ * A Logger interface
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.ship-simu.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/>.
+ */
+interface Logger extends FrameworkInterface {
+
+ // Logger levels
+ const LOGGER_LEVEL_DEBUG = 'DEBUG';
+ const LOGGER_LEVEL_DEPRECATED = 'DEPRECATED';
+ const LOGGER_LEVEL_INFO = 'INFO';
+ const LOGGER_LEVEL_TRACE = 'TRACE';
+ const LOGGER_LEVEL_WARNING = 'WARNING';
+
+ /**
+ * Outputs a trace message whether to debug instance (should be set!) or
+ * dies with or ptints the message. Do NEVER EVER rewrite the exit() call to
+ * ApplicationEntryPoint::app_exit(), this would cause an endless loop.
+ *
+ * @param $message Message we shall send out...
+ * @param $doPrint Whether print or die here (default: print)
+ * @paran $stripTags Whether to strip tags (default: false)
+ * @return void
+ * @throws InvalidArgumentException If a parameter has an invalid value
+ * @throws NullPointerException If this->outputInstance is NULL
+ * @todo Remove $doPrint parameter
+ */
+ public function traceMessage (string $message, bool $doPrint = true, bool $stripTags = false);
+
+ /**
+ * Outputs a debug message whether to debug instance (should be set!) or
+ * dies with or ptints the message. Do NEVER EVER rewrite the exit() call to
+ * ApplicationEntryPoint::app_exit(), this would cause an endless loop.
+ *
+ * @param $message Message we shall send out...
+ * @param $doPrint Whether print or die here (default: print)
+ * @paran $stripTags Whether to strip tags (default: false)
+ * @return void
+ * @throws InvalidArgumentException If a parameter has an invalid value
+ * @throws NullPointerException If this->outputInstance is NULL
+ * @todo Remove $doPrint parameter
+ */
+ public function debugMessage (string $message, bool $doPrint = true, bool $stripTags = false);
+
+ /**
+ * Outputs an informational message whether to debug instance (should be set!) or
+ * dies with or ptints the message. Do NEVER EVER rewrite the exit() call to
+ * ApplicationEntryPoint::app_exit(), this would cause an endless loop.
+ *
+ * @param $message Message we shall send out...
+ * @param $doPrint Whether print or die here (default: print)
+ * @paran $stripTags Whether to strip tags (default: false)
+ * @return void
+ * @throws InvalidArgumentException If a parameter has an invalid value
+ * @throws NullPointerException If this->outputInstance is NULL
+ * @todo Remove $doPrint parameter
+ */
+ public function infoMessage (string $message, bool $doPrint = true, bool $stripTags = false);
+
+ /**
+ * Outputs a warning message whether to debug instance (should be set!) or
+ * dies with or ptints the message. Do NEVER EVER rewrite the exit() call to
+ * ApplicationEntryPoint::app_exit(), this would cause an endless loop.
+ *
+ * @param $message Message we shall send out...
+ * @param $doPrint Whether print or die here (default: print)
+ * @paran $stripTags Whether to strip tags (default: false)
+ * @return void
+ * @throws InvalidArgumentException If a parameter has an invalid value
+ * @throws NullPointerException If this->outputInstance is NULL
+ * @todo Remove $doPrint parameter
+ */
+ public function warningMessage (string $message, bool $doPrint = true, bool $stripTags = false);
+
+ /**
+ * Output a partial stub message for the caller method
+ *
+ * @param $message An optional message to display
+ * @return void
+ */
+ public function partialStub (string $message = '');
+
+ /**
+ * Outputs a deprecated message whether to debug instance (should be set!) or
+ * dies with or ptints the message. Do NEVER EVER rewrite the exit() call to
+ * ApplicationEntryPoint::app_exit(), this would cause an endless loop.
+ *
+ * @param $message Message we shall send out...
+ * @param $doPrint Whether print or die here (default: print)
+ * @paran $stripTags Whether to strip tags (default: false)
+ * @return void
+ * @throws InvalidArgumentException If a parameter has an invalid value
+ * @throws NullPointerException If this->outputInstance is NULL
+ * @todo Remove $doPrint parameter
+ * @todo When all old method invocations are fixed, renamed this do deprecatedMessage
+ */
+ public function debugOutput (string $message, bool $doPrint = true, bool $stripTags = false);
+
+}
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
interface Register extends FrameworkInterface {
- /**
- * Checks whether an instance key was found
- *
- * @param $instanceKey The key holding an instance in registry
- * @return $exists Whether the key exists in registry
- */
- function instanceExists (string $instanceKey);
-
- /**
- * Adds/overwrites a new instance to the registry at the given key
- *
- * @param $instanceKey The key to identify the instance
- * @param $objectInstance An instance we shall store
- * @return void
- */
- function addInstance (string $instanceKey, Registerable $objectInstance);
/**
* Getter for whole generic registry
*/
function getGenericRegistry ();
- /**
- * Getter for whole instance registry
- *
- * @return $instanceRegistry The whole instance registry array
- */
- function getInstanceRegistry ();
-
/**
* Adds a new entry to the given list name. If you want to add objects
* please use addInstance() and getInstance() instead.
*/
function getArrayFromKey (string $arrayKey, string $lookFor);
- /**
- * Gets a registered instance or null if not found
- *
- * @param $instanceKey The key to identify the instance
- * @return $objectInstance An instance we shall store
- * @throws NullPointerException If the requested key is not found
- */
- function getInstance (string $instanceKey);
-
}
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
--- /dev/null
+<?php
+// Own namespace
+namespace Org\Mxchange\CoreFramework\Registry\Object;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Registry\Register;
+use Org\Mxchange\CoreFramework\Registry\Registerable;
+
+/**
+ * An interface for registries
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 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/>.
+ */
+interface ObjectRegister extends Register {
+ /**
+ * Checks whether an instance key was found
+ *
+ * @param $instanceKey The key holding an instance in registry
+ * @return $exists Whether the key exists in registry
+ */
+ function instanceExists (string $instanceKey);
+
+ /**
+ * Adds/overwrites a new instance to the registry at the given key
+ *
+ * @param $instanceKey The key to identify the instance
+ * @param $objectInstance An instance we shall store
+ * @return void
+ */
+ function addInstance (string $instanceKey, Registerable $objectInstance);
+
+ /**
+ * Getter for whole instance registry
+ *
+ * @return $instanceRegistry The whole instance registry array
+ */
+ function getInstanceRegistry ();
+
+ /**
+ * Gets a registered instance or null if not found
+ *
+ * @param $instanceKey The key to identify the instance
+ * @return $objectInstance An instance we shall store
+ * @throws NullPointerException If the requested key is not found
+ */
+ function getInstance (string $instanceKey);
+
+}
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
function getParameterNames ();
/**
- * Sets whether the request was valid (default: true)
+ * Sets whether the request was valid
*
* @param $isValid Whether the request is valid
* @return void
*/
- function requestIsValid (bool $isValid = true);
+ function setIsRequestValid (bool $isValid);
/**
* Returns whether this request is valid
*
- * @return $requestIsValid Whether this request is valid
+ * @return $isRequestValid Whether this request is valid
*/
function isRequestValid ();
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
* @param $stackerName Name of the stacker
* @param $value Value to push on it
* @return void
- * @throws StackerFullException If the stacker is full
+ * @throws BadMethodCallException If the stacker is full
*/
function pushNamed (string $stackerName, $value);
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Read all directories but no sub directories, .htaccess files and NullCompressor class
while ($directoryEntry = $directoryInstance->readDirectoryExcept(array('class_NullCompressor.php'))) {
- // Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('COMPRESSOR: directoryEntry=' . $directoryEntry);
-
// Is this a class file?
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('COMPRESSOR: directoryEntry=' . $directoryEntry);
if ((substr($directoryEntry, 0, 6) == 'class_') && (substr($directoryEntry, -4, 4) == '.php')) {
/* Get the compressor's name. That's why you must name
* your files like your classes and also that's why you
use Org\Mxchange\CoreFramework\Criteria\Criteria;
use Org\Mxchange\CoreFramework\Criteria\Storing\StoreableCriteria;
use Org\Mxchange\CoreFramework\Database\Backend\DatabaseBackend;
-use Org\Mxchange\CoreFramework\Registry\Registerable;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Middleware\BaseMiddleware;
-use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
+use Org\Mxchange\CoreFramework\Registry\Registerable;
+use Org\Mxchange\CoreFramework\Result\Database\BaseDatabaseResult;
// Import SPL stuff
use \InvalidArgumentException;
+use \OutOfBoundsException;
+use \UnexpectedValueException;
/**
- * Database selector class
+ * Database connectivity class
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
/**
* Array for connection data
*/
- private $connectData = array(
+ private $connectData = [
'login' => '',
'pass' => '',
'dbase' => '',
- 'host' => ''
- );
+ 'host' => '',
+ ];
/**
* The real database layer
/**
* Creates a new database connection layer
*
- * @param $debugInstance An instance of a DebugMiddleware class
* @param $backendInstance An instance of a DatabaseBackend class
* @todo $debugInstance is currently not used
*/
- public static final function createDatabaseConnection (DebugMiddleware $debugInstance, DatabaseBackend $backendInstance) {
+ public static final function createDatabaseConnection (DatabaseBackend $backendInstance) {
// Get instance
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('DATABASE-CONNECTION: backendInstance=%s - CALLED!', $backendInstance->__toString()));
$databaseInstance = new DatabaseConnection();
// Set database layer
- $databaseInstance->setDatabaseLayer($backendInstance);
+ $databaseInstance->setBackendInstance($backendInstance);
// Set db instance
self::$selfInstance = $databaseInstance;
// Return instance
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('DATABASE-CONNECTION: databaseInstance=%s - EXIT!', $databaseInstance->__toString()));
return $databaseInstance;
}
return self::$selfInstance;
}
+ /**
+ * Setter for the real database layer
+ * @param $backendInstance An instance of a DatabaseBackend class
+ * @return void
+ */
+ private final function setBackendInstance (DatabaseBackend $backendInstance) {
+ $this->backendInstance = $backendInstance;
+ }
+
/**
* Setter for all database connection data. All these parameters may be
* supported by the underlaying backend.
* @param $dbase Name of used database
* @param $host Host to connect to (default: 127.0.0.1)
* @return void
+ * @throws InvalidArgumentException If a parameter is empty
*/
- public final function setConnectionData (string $login, string $pass, string $dbase, string $host = '127.0.0.1') {
+ public final function setConnectionData (string $login, string $pass, string $dbase, string $host = 'localhost') {
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('DATABASE-CONNECTION: login=%s,pass=%s,dbase=%s,host=%s CALLED!', $login, $pass, $dbase, $host));
+ if (empty($login)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "login" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($dbase)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "dbase" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($host)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "host" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Transfer connection data
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('DATABASE-CONNECTION: Setting data ...');
$this->connectData['login'] = $login;
$this->connectData['pass'] = $pass;
$this->connectData['dbase'] = $dbase;
$this->connectData['host'] = $host;
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('DATABASE-CONNECTION: EXIT!');
}
/**
return $this->connectData;
}
- /**
- * Setter for the real database layer
- * @param $backendInstance An instance of a DatabaseBackend class
- * @return void
- */
- public final function setDatabaseLayer (DatabaseBackend $backendInstance) {
- $this->backendInstance = $backendInstance;
- }
-
/**
* Getter for index key
*
* @param $criteriaInstance An instance of a Criteria class
* @return $result The result as an array
* @throws InvalidArgumentException If a parameter is empty
+ * @throws OutOfBoundsException If important array elements are not present
+ * @throws UnexpectedValueException If $result['status'] is not 'ok'
*/
public function doSelectByTableCriteria (string $tableName, Criteria $criteriaInstance) {
// Validate parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('DATABASE-CONNECTION: tableName=%s,criteriaInstance=%s - CALLED!', $tableName, $criteriaInstance->__toString()));
if (empty($tableName)) {
// Throw IAE
- throw new InvalidArgumentException('Parameter "tableName" is empty');
+ throw new InvalidArgumentException('Parameter "tableName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
}
// Connect to the database
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('DATABASE-CONNECTION: Invoking this->backendInstance->connectToDatabase() ...');
$this->backendInstance->connectToDatabase();
// Get result from query
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('DATABASE-CONNECTION: Invoking this->backendInstance->querySelect(%s,%s) ...', $tableName, $criteriaInstance->__toString()));
$result = $this->backendInstance->querySelect($tableName, $criteriaInstance);
+ // Is a valid array returned?
+ if (!isset($result[BaseDatabaseResult::RESULT_NAME_STATUS])) {
+ // Missing element
+ throw new OutOfBoundsException(sprintf('result()=%d does not have element "%s"', count($result), BaseDatabaseResult::RESULT_NAME_STATUS), FrameworkInterface::EXCEPTION_OUT_OF_BOUNDS);
+ } elseif ($result[BaseDatabaseResult::RESULT_NAME_STATUS] != 'ok') {
+ // Is exception given?
+ if (isset($result[BaseDatabaseResult::RESULT_NAME_EXCEPTION])) {
+ // Attach it
+ throw new UnexpectedValueException(sprintf('result[%s]=%s is not "ok" with cause', BaseDatabaseResult::RESULT_NAME_STATUS), FrameworkInterface::EXCEPTION_INVALID_ARGUMENT, BaseDatabaseResult::RESULT_NAME_EXCEPTION);
+ } else {
+ // No exception attached
+ throw new UnexpectedValueException(sprintf('result[%s]=%s is not "ok"', BaseDatabaseResult::RESULT_NAME_STATUS, $result[BaseDatabaseResult::RESULT_NAME_STATUS]), FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+ }
+
// Return the result
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('DATABASE-CONNECTION: result[]=%s - EXIT!', gettype($result)));
return $result;
}
* @return $exceptionInstance Last thrown exception
*/
public final function getLastException () {
+ // Get instance
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('DATABASE-CONNECTION: CALLED!');
$exceptionInstance = $this->backendInstance->getLastException();
+
+ // Return it
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('DATABASE-CONNECTION: exceptionInstance=%s - EXIT!', $exceptionInstance->__toString()));
return $exceptionInstance;
}
*/
public function queryInsertDataSet (StoreableCriteria $dataSetInstance) {
// Connect to the database
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('DATABASE-CONNECTION: dataSetInstance=%s - CALLED!', $dataSetInstance->__toString()));
$this->backendInstance->connectToDatabase();
// Ask the database layer
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('DATABASE-CONNECTION: Invoking this->backendInstance->queryInsertDataSet(%s) ...', $dataSetInstance->__toString()));
$this->backendInstance->queryInsertDataSet($dataSetInstance);
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('DATABASE-CONNECTION: EXIT!');
}
/**
*/
public function queryUpdateDataSet (StoreableCriteria $dataSetInstance) {
// Connect to the database
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('DATABASE-CONNECTION: dataSetInstance=%s - CALLED!', $dataSetInstance->__toString()));
$this->backendInstance->connectToDatabase();
// Ask the database layer
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('DATABASE-CONNECTION: Invoking this->backendInstance->queryUpdateDataSet(%s) ...', $dataSetInstance->__toString()));
$this->backendInstance->queryUpdateDataSet($dataSetInstance);
+
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('DATABASE-CONNECTION: EXIT!');
}
/**
*/
public function getPrimaryKeyOfTable (string $tableName) {
// Validate parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('DATABASE-CONNECTION: tableName=%s - CALLED!', $tableName));
if (empty($tableName)) {
// Throw IAE
- throw new InvalidArgumentException('Parameter "tableName" is empty');
+ throw new InvalidArgumentException('Parameter "tableName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
}
// Connect to the database
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('DATABASE-CONNECTION: Invoking this->backendInstance->connectToDatabase() ...');
$this->backendInstance->connectToDatabase();
// Ask the database layer
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('DATABASE-CONNECTION: Invoking this->backendInstance->getPrimaryKeyOfTable(%s) ...', $tableName));
$primaryKey = $this->backendInstance->getPrimaryKeyOfTable($tableName);
// Return the value
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('DATABASE-CONNECTION: primaryKey=%s - CALLED!', $primaryKey));
return $primaryKey;
}
*
* @param $data An array with possible non-public data that needs to be removed.
* @return $data A cleaned up array with only public data.
+ * @throws InvalidArgumentException If a parameter has an invalid value
*/
public function removeNonPublicDataFromArray (array $data) {
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('DATABASE-CONNECTION: data()=%d - CALLED!', count($data)));
+ if (count($data) == 0) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "data" is an empty array', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Connect to the database
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('DATABASE-CONNECTION: Invoking this->backendInstance->connectToDatabase() ...');
$this->backendInstance->connectToDatabase();
// Call database backend
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DB-CONNECTION[' . $this->__toString() . ']: Calling this->backendInstance->removeNonPublicDataFromArray(data) ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('DATABASE-CONNECTION: Invoking this->backendInstance->removeNonPublicDataFromArray(data()=%d) ...', count($data)));
$data = $this->backendInstance->removeNonPublicDataFromArray($data);
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DB-CONNECTION[' . $this->__toString() . ']: data[]=' . gettype($data));
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('DATABASE-CONNECTION: data()=%d - EXIT!', count($data)));
return $data;
}
*/
public function countTotalRows (string $tableName) {
// Validate parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('DATABASE-CONNECTION: tableName=%s - CALLED!', $tableName));
if (empty($tableName)) {
// Throw IAE
- throw new InvalidArgumentException('Parameter "tableName" is empty');
+ throw new InvalidArgumentException('Parameter "tableName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
}
// Connect to the database
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('DATABASE-CONNECTION: Invoking this->backendInstance->connectToDatabase() ...');
$this->backendInstance->connectToDatabase();
// Ask the database layer
$count = $this->backendInstance->countTotalRows($tableName);
// Return the value
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('DATABASE-CONNECTION: count=%d - CALLED!', $count));
return $count;
}
// Import framework stuff
use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Generic\NullPointerException;
+use Org\Mxchange\CoreFramework\Logging\Logger;
use Org\Mxchange\CoreFramework\Middleware\BaseMiddleware;
use Org\Mxchange\CoreFramework\Registry\Registerable;
use Org\Mxchange\CoreFramework\Stream\Output\OutputStreamer;
+// Import SPL stuff
+use \InvalidArgumentException;
+
/**
* The middlware debug output system. A *real* or concrete output class shall
* become registered with this middleware because the back-fall class will
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @deprecated See LoggerFactory for a more flexible approach
* 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 DebugMiddleware extends BaseMiddleware implements Registerable {
+class DebugMiddleware extends BaseMiddleware implements Registerable, Logger {
/**
* An instance of this class
*/
*/
private function __construct () {
// Call parent constructor
+ //* NOISY-DEBUG: */ printf('[%s:%d]: CONSTRUCTED!' . PHP_EOL, __METHOD__, __LINE__);
parent::__construct(__CLASS__);
- // Set own instance
- self::$selfInstance = $this;
+ // Trace message
+ //* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__);
}
/**
* @param $className Class where a output should be created and
* configured for
* @return $debugInstance An instance of this middleware class
+ * @throws InvalidArgumentException If a parameter has an invalid value
*/
public static final function createDebugMiddleware (string $outputClass, string $className) {
- //* DEBUG-DIE: */ die(__METHOD__.': outputClass=' . $outputClass . ',className=' . $className);
-
- // Create an instance if this middleware
- $debugInstance = new DebugMiddleware();
+ // Check parameter
+ //* NOISY-DEBUG: */ printf('[%s:%d]: outputClass=%s,className=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $outputClass, $className);
+ if (empty($outputClass)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "outputClass" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (empty($className)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "className" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
- // Default is that $outputClass may be invalid
- $isInitialized = false;
+ // Is a static instance there?
+ //* NOISY-DEBUG: */ printf('[%s:%d]: self::selfInstance[]=%s' . PHP_EOL, __METHOD__, __LINE__, gettype(self::$selfInstance));
+ if (is_null(self::$selfInstance)) {
+ // Create an instance if this middleware
+ self::$selfInstance = new DebugMiddleware();
+ }
// Is there a valid output instance provided?
- if (class_exists($outputClass)) {
+ //* NOISY-DEBUG: */ printf('[%s:%d]: outputClass=%s' . PHP_EOL, __METHOD__, __LINE__, $outputClass);
+ if (class_exists($outputClass) && is_null(self::$selfInstance->getOutputInstance())) {
// A name for a debug output class has been provided so we try to get it
+ //* NOISY-DEBUG: */ printf('[%s:%d]: Initializing outputClass=%s ...' . PHP_EOL, __METHOD__, __LINE__, $outputClass);
$outputInstance = ObjectFactory::createObjectByName($outputClass);
// Set this as output class
- $debugInstance->setOutputInstance($outputInstance);
-
- // All fine
- $isInitialized = true;
+ //* NOISY-DEBUG: */ printf('[%s:%d]: outputInstance=%s' . PHP_EOL, __METHOD__, __LINE__, $outputInstance->__toString());
+ self::$selfInstance->setOutputInstance($outputInstance);
}
- // Is the output class initialized?
- if ($isInitialized === true) {
+ // Is the output class loadable and an output instance is set?
+ if (class_exists($outputClass) && !is_null(self::$selfInstance->getOutputInstance())) {
// Then set class name
- $debugInstance->getOutputInstance()->setLoggerClassName($className);
+ //* NOISY-DEBUG: */ printf('[%s:%d]: Setting className=%s as logger class ...' . PHP_EOL, __METHOD__, __LINE__, $className);
+ self::$selfInstance->getOutputInstance()->setLoggerClassName($className);
}
// Return instance
- return $debugInstance;
+ //* NOISY-DEBUG: */ printf('[%s:%d]: debugInstance=%s - EXIT!' . PHP_EOL, __METHOD__, __LINE__, self::$selfInstance->__toString());
+ return self::$selfInstance;
+ }
+
+ /**
+ * This method shall send debug output which can be HTML code for the
+ * browser or debug lines for a log file, etc. to the registered debug
+ * output instance.
+ *
+ * @param $message Data we shall 'stream' out to the world
+ * @param $stripTags Whether HTML tags shall be stripped out
+ * @return void
+ * @throws NullPointerException If this->outputInstance is NULL
+ */
+ private function outputMessage (string $logLevel, string $message, bool $stripTags = false) {
+ // Get backtrace
+ //* NOISY-DEBUG: */ printf('[%s:%d]: logLevel=%s,message=%s,stripTags=%d - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $logLevel, $message, intval($stripTags));
+ $backtrace = debug_backtrace(!DEBUG_BACKTRACE_PROVIDE_OBJECT);
+
+ // Is the deprecated debugOutput() or partialStub() invoked before?
+ if (isset($backtrace[4]) && $backtrace[3]['function'] == 'partialStub') {
+ // Prepend class::function:line from 2nd element
+ //* NOISY-DEBUG: */ printf('[%s:%d]: partialStub() was invoked ...' . PHP_EOL, __METHOD__, __LINE__);
+ $message = sprintf('[%s] [%s::%s:%d]: %s',
+ $logLevel,
+ $backtrace[4]['class'],
+ $backtrace[4]['function'],
+ (isset($backtrace[4]['line']) ? $backtrace[4]['line'] : '0'),
+ $message
+ );
+ } elseif (isset($backtrace[3]) && $backtrace[2]['function'] == 'debugOutput') {
+ // Prepend class::function:line from 2nd element
+ //* NOISY-DEBUG: */ printf('[%s:%d]: debugOutput() was invoked ...' . PHP_EOL, __METHOD__, __LINE__);
+ $message = sprintf('[%s] [%s::%s:%d]: %s',
+ $logLevel,
+ $backtrace[3]['class'],
+ $backtrace[3]['function'],
+ (isset($backtrace[3]['line']) ? $backtrace[3]['line'] : '0'),
+ $message
+ );
+ } else {
+ // Prepend class::function:line from 2nd element
+ //* NOISY-DEBUG: */ printf('[%s:%d]: Ordinary invocation ...' . PHP_EOL, __METHOD__, __LINE__);
+ $message = sprintf('[%s] [%s::%s:%d]: %s',
+ $logLevel,
+ $backtrace[2]['class'],
+ $backtrace[2]['function'],
+ (isset($backtrace[2]['line']) ? $backtrace[2]['line'] : '0'),
+ $message
+ );
+ }
+
+ // Use the output instance
+ $this->getOutputInstance()->outputStream($message, $stripTags);
+
+ // Trace message
+ //* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__);
}
/**
}
/**
- * This method shall send debug output which can be HTML code for the
- * browser or debug lines for a log file, etc. to the registered debug
- * output instance.
+ * Outputs a trace message whether to debug instance (should be set!) or
+ * dies with or ptints the message. Do NEVER EVER rewrite the exit() call to
+ * ApplicationEntryPoint::app_exit(), this would cause an endless loop.
*
- * @param $outStream Data we shall 'stream' out to the world
- * @param $stripTags Whether HTML tags shall be stripped out
+ * @param $message Message we shall send out...
+ * @param $doPrint Whether print or die here (default: print)
+ * @paran $stripTags Whether to strip tags (default: false)
* @return void
+ * @throws InvalidArgumentException If a parameter has an invalid value
+ * @throws NullPointerException If this->outputInstance is NULL
+ * @todo Remove $doPrint parameter
*/
- public final function output (string $outStream, bool $stripTags = false) {
- // Is the output stream set
- if (empty($outStream)) {
- // @TODO Initialization phase
- return;
+ public function traceMessage (string $message, bool $doPrint = true, bool $stripTags = false) {
+ // Check parameter
+ //* NOISY-DEBUG: */ printf('[%s:%d]: message=%s,doPrint=%d,stripTags=%d - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $message, intval($doPrint), intval($stripTags));
+ if (empty($message)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "message" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif (is_null($this->getOutputInstance())) {
// Should not be NULL
- throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
+ throw new NullPointerException($this, FrameworkInterface::EXCEPTION_IS_NULL_POINTER);
}
- // Use the output instance
- $this->getOutputInstance()->outputStream($outStream, $stripTags);
+ // Use debug output handler
+ //* NOISY-DEBUG: */ printf('[%s:%d]: Invoking this->outputMessage(%s,%s,%d) ...' . PHP_EOL, __METHOD__, __LINE__, Logger::LOGGER_LEVEL_TRACE, $message, intval($stripTags));
+ $this->outputMessage(Logger::LOGGER_LEVEL_TRACE, $message, $stripTags);
+
+ // Trace message
+ //* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__);
+ }
+
+ /**
+ * Outputs a debug message whether to debug instance (should be set!) or
+ * dies with or ptints the message. Do NEVER EVER rewrite the exit() call to
+ * ApplicationEntryPoint::app_exit(), this would cause an endless loop.
+ *
+ * @param $message Message we shall send out...
+ * @param $doPrint Whether print or die here (default: print)
+ * @paran $stripTags Whether to strip tags (default: false)
+ * @return void
+ * @throws InvalidArgumentException If a parameter has an invalid value
+ * @throws NullPointerException If this->outputInstance is NULL
+ * @todo Remove $doPrint parameter
+ */
+ public function debugMessage (string $message, bool $doPrint = true, bool $stripTags = false) {
+ // Check parameter
+ //* NOISY-DEBUG: */ printf('[%s:%d]: message=%s,doPrint=%d,stripTags=%d - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $message, intval($doPrint), intval($stripTags));
+ if (empty($message)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "message" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (is_null($this->getOutputInstance())) {
+ // Should not be NULL
+ throw new NullPointerException($this, FrameworkInterface::EXCEPTION_IS_NULL_POINTER);
+ }
+
+ // Use debug output handler
+ //* NOISY-DEBUG: */ printf('[%s:%d]: Invoking this->outputMessage(%s,%s,%d) ...' . PHP_EOL, __METHOD__, __LINE__, $message, intval($stripTags));
+ $this->outputMessage(Logger::LOGGER_LEVEL_DEBUG, $message, $stripTags);
+
+ // Trace message
+ //* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__);
+ }
+
+ /**
+ * Outputs an informational message whether to debug instance (should be set!) or
+ * dies with or ptints the message. Do NEVER EVER rewrite the exit() call to
+ * ApplicationEntryPoint::app_exit(), this would cause an endless loop.
+ *
+ * @param $message Message we shall send out...
+ * @param $doPrint Whether print or die here (default: print)
+ * @paran $stripTags Whether to strip tags (default: false)
+ * @return void
+ * @throws InvalidArgumentException If a parameter has an invalid value
+ * @throws NullPointerException If this->outputInstance is NULL
+ * @todo Remove $doPrint parameter
+ */
+ public function infoMessage (string $message, bool $doPrint = true, bool $stripTags = false) {
+ // Check parameter
+ //* NOISY-DEBUG: */ printf('[%s:%d]: message=%s,doPrint=%d,stripTags=%d - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $message, intval($doPrint), intval($stripTags));
+ if (empty($message)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "message" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (is_null($this->getOutputInstance())) {
+ // Should not be NULL
+ throw new NullPointerException($this, FrameworkInterface::EXCEPTION_IS_NULL_POINTER);
+ }
+
+ // Use debug output handler
+ //* NOISY-DEBUG: */ printf('[%s:%d]: Invoking this->outputMessage(%s,%s,%d) ...' . PHP_EOL, __METHOD__, __LINE__, Logger::LOGGER_LEVEL_INFO, $message, intval($stripTags));
+ $this->outputMessage(Logger::LOGGER_LEVEL_INFO, $message, $stripTags);
+
+ // Trace message
+ //* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__);
+ }
+
+ /**
+ * Outputs a warning message whether to debug instance (should be set!) or
+ * dies with or ptints the message. Do NEVER EVER rewrite the exit() call to
+ * ApplicationEntryPoint::app_exit(), this would cause an endless loop.
+ *
+ * @param $message Message we shall send out...
+ * @param $doPrint Whether print or die here (default: print)
+ * @paran $stripTags Whether to strip tags (default: false)
+ * @return void
+ * @throws InvalidArgumentException If a parameter has an invalid value
+ * @throws NullPointerException If this->outputInstance is NULL
+ * @todo Remove $doPrint parameter
+ */
+ public function warningMessage (string $message, bool $doPrint = true, bool $stripTags = false) {
+ // Check parameter
+ //* NOISY-DEBUG: */ printf('[%s:%d]: message=%s,doPrint=%d,stripTags=%d - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $message, intval($doPrint), intval($stripTags));
+ if (empty($message)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "message" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (is_null($this->getOutputInstance())) {
+ // Should not be NULL
+ throw new NullPointerException($this, FrameworkInterface::EXCEPTION_IS_NULL_POINTER);
+ }
+
+ // Use debug output handler
+ //* NOISY-DEBUG: */ printf('[%s:%d]: Invoking this->outputMessage(%s,%s,%d) ...' . PHP_EOL, __METHOD__, __LINE__, Logger::LOGGER_LEVEL_WARNING, $message, intval($stripTags));
+ $this->outputMessage(Logger::LOGGER_LEVEL_WARNING, $message, $stripTags);
+
+ // Trace message
+ //* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__);
+ }
+
+ /**
+ * Output a partial stub message for the caller method
+ *
+ * @param $message An optional message to display
+ * @return void
+ */
+ public function partialStub (string $message = '') {
+ // Init variable
+ //* NOISY-DEBUG: */ printf('[%s:%d]: message=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $message);
+ $stubMessage = 'Partial stub!';
+
+ // Is an extra message given?
+ if (!empty($message)) {
+ // Then add it as well
+ $stubMessage .= ' Message: ' . $message;
+ }
+
+ // Output stub message
+ //* NOISY-DEBUG: */ printf('[%s:%d]: Invoking this->outputMessage(%s,%s) ...' . PHP_EOL, __METHOD__, __LINE__, Logger::LOGGER_LEVEL_WARNING, $subMessage);
+ $this->outputMessage(Logger::LOGGER_LEVEL_WARNING, $stubMessage);
+
+ // Trace message
+ //* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__);
+ }
+
+ /**
+ * Outputs a deprecated message whether to debug instance (should be set!) or
+ * dies with or ptints the message. Do NEVER EVER rewrite the exit() call to
+ * ApplicationEntryPoint::app_exit(), this would cause an endless loop.
+ *
+ * @param $message Message we shall send out...
+ * @param $doPrint Whether print or die here (default: print)
+ * @paran $stripTags Whether to strip tags (default: false)
+ * @return void
+ * @throws InvalidArgumentException If a parameter has an invalid value
+ * @throws NullPointerException If this->outputInstance is NULL
+ * @todo Remove $doPrint parameter
+ * @todo When all old method invocations are fixed, renamed this do deprecatedMessage
+ */
+ public function debugOutput (string $message, bool $doPrint = true, bool $stripTags = false) {
+ // Check parameter
+ //* NOISY-DEBUG: */ printf('[%s:%d]: message=%s,doPrint=%d,stripTags=%d - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $message, intval($doPrint), intval($stripTags));
+ if (empty($message)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "message" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif (is_null($this->getOutputInstance())) {
+ // Should not be NULL
+ throw new NullPointerException($this, FrameworkInterface::EXCEPTION_IS_NULL_POINTER);
+ }
+
+ // Invoke Inner method
+ //* NOISY-DEBUG: */ printf('[%s:%d]: Invoking this->outputMessage(%s,%s) ...' . PHP_EOL, __METHOD__, __LINE__, Logger::LOGGER_LEVEL_DEPRECATED, $subMessage);
+ $this->outputMessage(Logger::LOGGER_LEVEL_DEPRECATED, $message, $doPrint, $stripTags);
+
+ // Trace message
+ //* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__);
}
}
use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
use Org\Mxchange\CoreFramework\Handler\Stream\IoHandler;
use Org\Mxchange\CoreFramework\Middleware\BaseMiddleware;
+use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
use Org\Mxchange\CoreFramework\Traits\Streamer\File\Input\FileInputStreamerTrait;
use Org\Mxchange\CoreFramework\Traits\Streamer\File\Output\FileOutputStreamerTrait;
// Import SPL stuff
+use \InvalidArgumentException;
use \SplFileInfo;
/**
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*/
private function __construct () {
// Call parent constructor
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('FILE-IO-HANDLER: CONSTRUCTED!');
parent::__construct(__CLASS__);
// Set own instance
self::$selfInstance = $this;
+
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('FILE-IO-HANDLER: EXIT!');
}
/**
* Creates an instance of this class and prepares the IO system. This is
* being done by setting the default file IO class
*
- * @return $ioInstance A prepared instance of FilIOHandler
+ * @return $ioHandlerInstance A prepared instance of FilIoHandler
*/
public static final function createFileIoHandler () {
// Get instance
- $ioHandler = new FileIoHandler();
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('FILE-IO-HANDLER: CALLED!');
+ $ioHandlerInstance = new FileIoHandler();
// Set the *real* file IO instances (both the same)
- $ioHandler->setInputStreamerInstance(ObjectFactory::createObjectByConfiguredName('file_input_class'));
- $ioHandler->setOutputStreamerInstance(ObjectFactory::createObjectByConfiguredName('file_output_class'));
+ $ioHandlerInstance->setInputStreamerInstance(ObjectFactory::createObjectByConfiguredName('file_input_class'));
+ $ioHandlerInstance->setOutputStreamerInstance(ObjectFactory::createObjectByConfiguredName('file_output_class'));
// Return instance
- return $ioHandler;
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('FILE-IO-HANDLER: ioHandlerInstance=%s - EXIT!', $ioHandlerInstance->__toString()));
+ return $ioHandlerInstance;
}
/**
* @return $selfInstance An instance of this class
*/
public static final function getSelfInstance () {
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('FILE-IO-HANDLER: Returning self::selfInstance[]=%s - EXIT!', gettype(self::$selfInstance)));
return self::$selfInstance;
}
* @throws UnsupportedOperationException If this method is called
*/
public function saveFile (SplFileInfo $infoInstance, array $dataArray) {
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('infoInstance.pathname=' . $infoInstance->getPathname() . ',dataArray()=' . count($dataArray));
- throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+ // Trace message for logging parameters
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('FILE-IO-HANDLER: infoInstance.pathname=%s,dataArray()=%d - CALLED!', $infoInstance->getPathname(), count($dataArray)));
+ throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
* @param $dataStream File data stream
* @param $objectInstance An instance of a FrameworkInterface class (default: NULL)
* @return void
+ * @throws InvalidArgumentException If a parameter has an invalid value
*/
public function saveStreamToFile (SplFileInfo $infoInstance, string $dataStream, FrameworkInterface $objectInstance = NULL) {
+ // Check parameters
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('FILE-IO-HANDLER: infoInstance=%s,dataStream()=%d,objectInstance[]=%s - CALLED!', $infoInstance->__toString(), strlen($dataStream), gettype($objectInstance)));
+ if (empty($dataStream)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "dataStream" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
// Default is this array
$className = $this->__toString();
// Is the object instance set?
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('FILE-IO-HANDLER: className=%s - BEFORE!', $className));
if ($objectInstance instanceof FrameworkInterface) {
// Then use this
$className = $objectInstance->__toString();
}
- // Prepare output array
- $dataArray = array(
+ // Send the infoInstance and data array to the output handler
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('FILE-IO-HANDLER: className=%s - AFTER!', $className));
+ $this->getOutputStreamerInstance()->saveFile($infoInstance, [
0 => $className,
1 => $dataStream
- );
+ ]);
- // Send the infoInstance and dataArray to the output handler
- $this->getOutputStreamerInstance()->saveFile($infoInstance, $dataArray);
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('FILE-IO-HANDLER: EXIT!');
}
/** Loads data from a file over the input handler
*/
public function loadFileContents (SplFileInfo $infoInstance) {
// Read from the input handler
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('FILE-IO-HANDLER: infoInstance=%s - CALLED!', $infoInstance->__toString()));
return $this->getInputStreamerInstance()->loadFileContents($infoInstance);
}
* @todo 0% done
*/
public function determineSeekPosition () {
- $this->partialStub();
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('FILE-IO-HANDLER: CALLED!');
+ DebugMiddleware::getSelfInstance()->partialStub();
+
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('FILE-IO-HANDLER: EXIT!');
}
/**
* @param $offset Offset to seek to (or used as "base" for other seeks)
* @param $whence Added to offset (default: only use offset to seek to)
* @return void
+ * @throws InvalidArgumentException If a parameter has an invalid value
*/
public function seek (int $offset, int $whence = SEEK_SET) {
- $this->partialStub('offset=' . $offset . ',whence=' . $whence);
+ // Check parameter
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('FILE-IO-HANDLER: offset=%d,whence=%d - CALLED!', $offset, $whence));
+ if ($offset < 0) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "offset" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ }
+
+ // @TODO Unfinished work
+ DebugMiddleware::getSelfInstance()->partialStub('offset=' . $offset . ',whence=' . $whence);
+
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('FILE-IO-HANDLER: EXIT!');
}
/**
* Size of file stack
*
* @return $size Size (in bytes) of file
+ * @todo 0% done
*/
public function size () {
- $this->partialStub();
+ // @TODO: Unfinished method:
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('FILE-IO-HANDLER: CALLED!');
+ DebugMiddleware::getSelfInstance()->partialStub();
+
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('FILE-IO-HANDLER: EXIT!');
}
/**
* @todo 0% done
*/
public function getPosition () {
- $this->partialStub();
+ // @TODO: Unfinished method:
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('FILE-IO-HANDLER: CALLED!');
+ DebugMiddleware::getSelfInstance()->partialStub();
+
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('FILE-IO-HANDLER: EXIT!');
}
}
+++ /dev/null
-<?php
-// Own namespace
-namespace Org\Mxchange\CoreFramework\Tests\Command;
-
-// Import framework stuff
-use Org\Mxchange\CoreFramework\Command\BaseCommand;
-use Org\Mxchange\CoreFramework\Command\Commandable;
-use Org\Mxchange\CoreFramework\Controller\Controller;
-use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
-use Org\Mxchange\CoreFramework\Request\Requestable;
-use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver;
-use Org\Mxchange\CoreFramework\Response\Responseable;
-
-/**
- * A command for the 'main' routine
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 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 TestsConsoleMainCommand extends BaseCommand implements Commandable {
- /**
- * Protected constructor
- *
- * @return void
- */
- private function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this class
- *
- * @param $resolverInstance An instance of a command resolver class
- * @return $commandInstance An instance a prepared command class
- */
- public static final function createTestsConsoleMainCommand (CommandResolver $resolverInstance) {
- // Get new instance
- $commandInstance = new TestsConsoleMainCommand();
-
- // Set the application instance
- $commandInstance->setResolverInstance($resolverInstance);
-
- // Return the prepared instance
- return $commandInstance;
- }
-
- /**
- * Executes the given command with given request and response objects
- *
- * @param $requestInstance An instance of a class with an Requestable interface
- * @param $responseInstance An instance of a class with an Responseable interface
- * @return void
- */
- public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- // Debug message
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MAIN: --- Starting tests ... ---');
-
- // Get controller
- $controllerInstance = GenericRegistry::getRegistry()->getInstance('controller');
-
- // Run all tests
- $controllerInstance->executeTestsFilters($requestInstance, $responseInstance);
-
- // Debug message
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MAIN: --- Leaving main ... ---');
- }
-
- /**
- * Adds extra filters to the given controller instance
- *
- * @param $controllerInstance A controller instance
- * @param $requestInstance An instance of a class with an Requestable interface
- * @return void
- */
- public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
- // Add pre filters (e.g. for requirements checks)
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('tests_php_requirements_filter_class'));
-
- // Add 'tests' filters which will run the actual tests
- $controllerInstance->addTestsFilter(ObjectFactory::createObjectByConfiguredName('tests_configuration_classes_loadable_test_filter_class'));
- }
-
-}
+++ /dev/null
-<?php
-// Own namespace
-namespace Org\Mxchange\CoreFramework\Tests\Controller;
-
-// Import framework stuff
-use Org\Mxchange\CoreFramework\Controller\BaseController;
-use Org\Mxchange\CoreFramework\Controller\Controller;
-use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
-use Org\Mxchange\CoreFramework\Filter\Filterable;
-use Org\Mxchange\CoreFramework\Request\Requestable;
-use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver;
-use Org\Mxchange\CoreFramework\Response\Responseable;
-
-/**
- * The default controller with news for e.g. home or news page
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 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 TestsConsoleDefaultNewsController extends BaseController implements Controller {
- /**
- * Protected constructor
- *
- * @return void
- */
- private function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
-
- // Init additional filter chains
- foreach (array('bootstrap', 'tests', 'shutdown') as $filterChain) {
- $this->initFilterChain($filterChain);
- }
- }
-
- /**
- * Creates an instance of this class
- *
- * @param $resolverInstance An instance of a command resolver class
- * @return $controllerInstance A prepared instance of this class
- */
- public static final function createTestsConsoleDefaultNewsController (CommandResolver $resolverInstance) {
- // Create the instance
- $controllerInstance = new TestsConsoleDefaultNewsController();
-
- // Set the command resolver
- $controllerInstance->setResolverInstance($resolverInstance);
-
- // Add news filters to this controller
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_download_filter_class'));
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_process_filter_class'));
-
- // Return the prepared instance
- return $controllerInstance;
- }
-
- /**
- * Handles the given request and response
- *
- * @param $requestInstance An instance of a request class
- * @param $responseInstance An instance of a response class
- * @return void
- */
- public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) {
- // Get the command instance from the resolver by sending a request instance to the resolver
- $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance);
-
- // Add more filters by the command
- $commandInstance->addExtraFilters($this, $requestInstance);
-
- // Run the pre filters
- $this->executePreFilters($requestInstance, $responseInstance);
-
- // This request was valid! :-D
- $requestInstance->requestIsValid();
-
- // Execute the command
- $commandInstance->execute($requestInstance, $responseInstance);
-
- // Run the post filters
- $this->executePostFilters($requestInstance, $responseInstance);
-
- // Flush the response out
- $responseInstance->flushBuffer();
- }
-
- /**
- * Add a bootstrap filter
- *
- * @param $filterInstance A Filterable class
- * @return void
- */
- public function addBootstrapFilter (Filterable $filterInstance) {
- $this->addFilter('bootstrap', $filterInstance);
- }
-
- /**
- * Add a tests filter
- *
- * @param $filterInstance A Filterable class
- * @return void
- */
- public function addTestsFilter (Filterable $filterInstance) {
- $this->addFilter('tests', $filterInstance);
- }
-
- /**
- * Executes all bootstrap filters
- *
- * @param $requestInstance A Requestable class
- * @param $responseInstance A Responseable class
- * @return void
- */
- public function executeBootstrapFilters (Requestable $requestInstance, Responseable $responseInstance) {
- $this->executeFilters('bootstrap', $requestInstance, $responseInstance);
- }
-
- /**
- * Executes all tests filters
- *
- * @param $requestInstance A Requestable class
- * @param $responseInstance A Responseable class
- * @return void
- */
- public function executeTestsFilters (Requestable $requestInstance, Responseable $responseInstance) {
- $this->executeFilters('tests', $requestInstance, $responseInstance);
- }
-
-}
+++ /dev/null
-<?php
-// Own namespace
-namespace Org\Mxchange\CoreFramework\Tests\Filter;
-
-// Import framework stuff
-use Org\Mxchange\CoreFramework\Filter\BaseFilter;
-
-/**
- * A generic filter for tests
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 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/>.
- */
-abstract class BaseTestsFilter extends BaseFilter {
- /**
- * Protected constructor
- *
- * @param $className Real name of class
- * @return void
- */
- protected function __construct (string $className) {
- // Call parent constructor
- parent::__construct($className);
- }
-
-}
+++ /dev/null
-<?php
-// Own namespace
-namespace Org\Mxchange\CoreFramework\Tests\Filter\!!!;
-
-// Import framework stuff
-use Org\Mxchange\CoreFramework\Filter\Filterable;
-use Org\Mxchange\CoreFramework\Request\Requestable;
-use Org\Mxchange\CoreFramework\Response\Responseable;
-use Org\Mxchange\CoreFramework\Tests\Filter\BaseTestsFilter;
-
-/**
- * A ??? filter for tests
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.ship-simu.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 Tests???Filter extends BaseTestsFilter implements Filterable {
- /**
- * Protected constructor
- *
- * @return void
- */
- private function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this filter class
- *
- * @return $filterInstance An instance of this filter class
- */
- public final static function createTests???Filter () {
- // Get a new instance
- $filterInstance = new Tests???Filter();
-
- // Return the instance
- return $filterInstance;
- }
-
- /**
- * Executes the filter with given request and response objects
- *
- * @param $requestInstance An instance of a class with an Requestable interface
- * @param $responseInstance An instance of a class with an Responseable interface
- * @return void
- * @todo 0% done
- */
- public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- // Implement this!
- $this->partialStub('Please implement this method.');
- }
-
-}
+++ /dev/null
-<?php
-// Own namespace
-namespace Org\Mxchange\CoreFramework\Tests\Filter\Configuration\!!!;
-
-// Import framework stuff
-use Org\Mxchange\CoreFramework\Filter\Filterable;
-use Org\Mxchange\CoreFramework\Request\Requestable;
-use Org\Mxchange\CoreFramework\Response\Responseable;
-use Org\Mxchange\CoreFramework\Tests\Filter\BaseTestsFilter;
-
-/**
- * A ??? filter for tests
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.ship-simu.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 TestConfiguration???Filter extends BaseTestsFilter implements Filterable {
- /**
- * Protected constructor
- *
- * @return void
- */
- private function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this filter class
- *
- * @return $filterInstance An instance of this filter class
- */
- public final static function createTestConfiguration???Filter () {
- // Get a new instance
- $filterInstance = new TestConfiguration???Filter();
-
- // Return the instance
- return $filterInstance;
- }
-
- /**
- * Executes the filter with given request and response objects
- *
- * @param $requestInstance An instance of a class with an Requestable interface
- * @param $responseInstance An instance of a class with an Responseable interface
- * @return void
- * @todo 0% done
- */
- public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- // Implement this!
- $this->partialStub('Please implement this method.');
- }
-
-}
+++ /dev/null
-<?php
-// Own namespace
-namespace Org\Mxchange\CoreFramework\Tests\Filter\Configuration\Classes;
-
-// Import framework stuff
-use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
-use Org\Mxchange\CoreFramework\Filter\Filterable;
-use Org\Mxchange\CoreFramework\Request\Requestable;
-use Org\Mxchange\CoreFramework\Response\Responseable;
-use Org\Mxchange\CoreFramework\Tests\Filter\BaseTestsFilter;
-
-// Import SPL stuff
-use \InvalidArgumentException;
-
-/**
- * A LoadableClasses filter for tests
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.ship-simu.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 TestConfigurationLoadableClassesFilter extends BaseTestsFilter implements Filterable {
- /**
- * Protected constructor
- *
- * @return void
- */
- private function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this filter class
- *
- * @return $filterInstance An instance of this filter class
- */
- public final static function createTestConfigurationLoadableClassesFilter () {
- // Get a new instance
- $filterInstance = new TestConfigurationLoadableClassesFilter();
-
- // Return the instance
- return $filterInstance;
- }
-
- /**
- * Executes the filter with given request and response objects
- *
- * @param $requestInstance An instance of a class with an Requestable interface
- * @param $responseInstance An instance of a class with an Responseable interface
- * @return void
- * @todo 0% done
- */
- public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- // Init counter
- $passed = 0;
- $failed = 0;
-
- // Loop through all configuration keys
- foreach (FrameworkBootstrap::getConfigurationInstance()->getConfigurationArray() as $configKey => $configValue) {
- // Key must end with _class
- if (substr($configKey, -6, 6) != '_class') {
- // Skip this
- continue;
- }
-
- // Output message
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('Testing configKey[%s]=%s,configValue[%s]=%s', gettype($configKey), $configKey, gettype($configValue), $configValue));
-
- // This may throw exceptions
- try {
- // Is the config entry valid and class is there?
- if (!is_string($configValue)) {
- // Is not a string
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('configValue=%s has unexpected type "%s". FAILED', $configValue, gettype($configValue)));
-
- // Skip further tests
- $failed++;
- continue;
- } elseif (!class_exists($configValue)) {
- // Class not found
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('Class "%s" not found. FAILED', $configValue));
-
- // Skip further tests
- $failed++;
- continue;
- }
- } catch (InvalidArgumentException $e) {
- // Maybe not conform?
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('Class "%s" failed to load. Message: "%s"', $configValue, $e->getMessage()));
-
- // Skip further tests
- $failed++;
- continue;
- }
-
- // class_exists() didn't fail
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('Class "%s" loaded successfully. OKAY', $configValue));
- $passed++;
- }
-
- // Output result
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('Test result: %d okay, %d failed (%0.02f%% passed)', $passed, $failed, ($passed / ($passed + $failed) * 100)));
- }
-
-}
+++ /dev/null
-<?php
-// Own namespace
-namespace Org\Mxchange\CoreFramework\Tests\Filter\Requirements;
-
-// Import framework stuff
-use Org\Mxchange\CoreFramework\Filter\Filterable;
-use Org\Mxchange\CoreFramework\Request\Requestable;
-use Org\Mxchange\CoreFramework\Response\Responseable;
-use Org\Mxchange\CoreFramework\Tests\Filter\BaseTestsFilter;
-
-/**
- * A PhpRequirements filter for tests
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.ship-simu.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 TestsPhpRequirementsFilter extends BaseTestsFilter implements Filterable {
- /**
- * Protected constructor
- *
- * @return void
- */
- private function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this filter class
- *
- * @return $filterInstance An instance of this filter class
- */
- public final static function createTestsPhpRequirementsFilter () {
- // Get a new instance
- $filterInstance = new TestsPhpRequirementsFilter();
-
- // Return the instance
- return $filterInstance;
- }
-
- /**
- * Executes the filter with given request and response objects
- *
- * @param $requestInstance An instance of a class with an Requestable interface
- * @param $responseInstance An instance of a class with an Responseable interface
- * @return void
- * @todo 0% done
- */
- public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- // Implement this!
- $this->partialStub('Please implement this method.');
- }
-
-}
+++ /dev/null
-<?php
-// Own namespace
-namespace Org\Mxchange\CoreFramework\Tests\Resolver\Command;
-
-// Import framework stuff
-use Org\Mxchange\CoreFramework\Command\InvalidCommandException;
-use Org\Mxchange\CoreFramework\Resolver\Command\BaseCommandResolver;
-use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver;
-
-// Import SPL stuff
-use \InvalidArgumentException;
-
-/**
- * A command resolver for console commands
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 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 TestsConsoleCommandResolver extends BaseCommandResolver implements CommandResolver {
- /**
- * Protected constructor
- *
- * @return void
- */
- private function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
-
- // Set prefix to "TestsConsole"
- $this->setClassPrefix('tests_console');
- }
-
- /**
- * Creates an instance of a TestsConsole command resolver with a given default command
- *
- * @param $commandName The default command we shall execute
- * @return $resolverInstance The prepared command resolver instance
- * @throws InvalidArgumentException Thrown if default command is not set
- * @throws InvalidCommandException Thrown if default command is invalid
- */
- public static final function createTestsConsoleCommandResolver (string $commandName) {
- // Create the new instance
- $resolverInstance = new TestsConsoleCommandResolver();
-
- // Is the variable $commandName set and the command is valid?
- if (empty($commandName)) {
- // Then thrown an exception here
- throw new InvalidArgumentException('Parameter "commandName" is empty');
- } elseif ($resolverInstance->isCommandValid('Org\Mxchange\CoreFramework\Tests\Command', $commandName) === false) {
- // Invalid command found
- throw new InvalidCommandException(array($resolverInstance, $commandName), self::EXCEPTION_INVALID_COMMAND);
- }
-
- // Set namespace for command
- $resolverInstance->setNamespace('Org\Mxchange\CoreFramework\Tests\Command');
- $resolverInstance->setCommandName($commandName);
-
- // Return the prepared instance
- return $resolverInstance;
- }
-
-}
+++ /dev/null
-<?php
-// Own namespace
-namespace Org\Mxchange\CoreFramework\Tests\Resolver\Controller;
-
-// Import framework stuff
-use Org\Mxchange\CoreFramework\Controller\BaseController;
-use Org\Mxchange\CoreFramework\Controller\Controller;
-use Org\Mxchange\CoreFramework\Controller\InvalidControllerException;
-use Org\Mxchange\CoreFramework\Resolver\Controller\BaseControllerResolver;
-use Org\Mxchange\CoreFramework\Resolver\Controller\ControllerResolver;
-
-// Import SPL stuff
-use \InvalidArgumentException;
-
-/**
- * A resolver for resolving controllers locally
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 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 TestsConsoleControllerResolver extends BaseControllerResolver implements ControllerResolver {
- /**
- * Protected constructor
- *
- * @return void
- */
- private function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
-
- // Set prefix to "TestsConsole"
- $this->setClassPrefix('tests_console');
- }
-
- /**
- * Creates an instance of a resolver class with a given command
- *
- * @param $controllerName The controller we shall resolve
- * @return $resolverInstance The prepared controller resolver instance
- * @throws InvalidArgumentException Thrown if default command is not set
- * @throws InvalidControllerException Thrown if default controller is invalid
- */
- public static final function createTestsConsoleControllerResolver (string $controllerName) {
- // Create the new instance
- $resolverInstance = new TestsConsoleControllerResolver();
-
- // Is the variable $controllerName set and the command is valid?
- if (empty($controllerName)) {
- // Then thrown an exception here
- throw new InvalidArgumentException('Parameter "controllerName" is empty');
- } elseif ($resolverInstance->isControllerValid('Org\Mxchange\CoreFramework\Tests\Controller', $controllerName) === false) {
- // Invalid command found
- throw new InvalidControllerException(array($resolverInstance, $controllerName), self::EXCEPTION_INVALID_CONTROLLER);
- }
-
- // Set namespace and controller name
- $resolverInstance->setNamespace('Org\Mxchange\CoreFramework\Tests\Controller');
- $resolverInstance->setControllerName($controllerName);
-
- // Return the prepared instance
- return $resolverInstance;
- }
-
-}
+++ /dev/null
-<?php
-/**
- * 01.07.2008 22:32:28est
- *
- * Akismet PHP4 class
- *
- * <b>Usage</b>
- * <code>
- * $comment = array(
- * 'author' => 'viagra-test-123',
- * 'email' => 'test@example.com',
- * 'website' => 'http://www.example.com/',
- * 'body' => 'This is a test comment',
- * 'permalink' => 'http://yourdomain.com/yourblogpost.url',
- * );
- *
- * $akismet = new Akismet('http://www.yourdomain.com/', 'YOUR_WORDPRESS_API_KEY', $comment);
- *
- * if($akismet->errorsExist()) {
- * echo"Couldn't connected to Akismet server!";
- * } else {
- * if($akismet->isSpam()) {
- * echo"Spam detected";
- * } else {
- * echo"yay, no spam!";
- * }
- * }
- * </code>
- *
- * @author Bret Kuhns {@link www.miphp.net}
- * @link http://www.miphp.net/blog/view/new_akismet_class/
- * @version 0.3.4
- * @license http://www.opensource.org/licenses/mit-license.php MIT License
- */
-
-
-
-// Error constants
-define("AKISMET_SERVER_NOT_FOUND", 0);
-define("AKISMET_RESPONSE_FAILED", 1);
-define("AKISMET_INVALID_KEY", 2);
-
-
-
-// Base class to assist in error handling between Akismet classes
-class AkismetObject {
- var $errors = array();
-
-
- /**
- * Add a new error to the errors array in the object
- *
- * @param String $name A name (array key) for the error
- * @param String $string The error message
- * @return void
- */
- // Set an error in the object
- function setError($name, $message) {
- $this->errors[$name] = $message;
- }
-
-
- /**
- * Return a specific error message from the errors array
- *
- * @param String $name The name of the error you want
- * @return mixed Returns a String if the error exists, a false boolean if it does not exist
- */
- function getError($name) {
- if($this->isError($name)) {
- return $this->errors[$name];
- } else {
- return false;
- }
- }
-
-
- /**
- * Return all errors in the object
- *
- * @return String[]
- */
- function getErrors() {
- return (array)$this->errors;
- }
-
-
- /**
- * Check if a certain error exists
- *
- * @param String $name The name of the error you want
- * @return boolean
- */
- function isError($name) {
- return isset($this->errors[$name]);
- }
-
-
- /**
- * Check if any errors exist
- *
- * @return boolean
- */
- function errorsExist() {
- return (count($this->errors) > 0);
- }
-
-
-}
-
-
-
-
-
-// Used by the Akismet class to communicate with the Akismet service
-class AkismetHttpClient extends AkismetObject {
- var $akismetVersion = '1.1';
- var $con;
- var $host;
- var $port;
- var $apiKey;
- var $blogUrl;
- var $errors = array();
-
-
- // Constructor
- function AkismetHttpClient($host, $blogUrl, $apiKey, $port = 80) {
- $this->host = $host;
- $this->port = $port;
- $this->blogUrl = $blogUrl;
- $this->apiKey = $apiKey;
- }
-
-
- // Use the connection active in $con to get a response from the server and return that response
- function getResponse($request, $path, $type = "post", $responseLength = 1160) {
- $this->_connect();
-
- if($this->con && !$this->isError(AKISMET_SERVER_NOT_FOUND)) {
- $request =
- strToUpper($type)." /{$this->akismetVersion}/$path HTTP/1.1\r\n" .
- "Host: ".((!empty($this->apiKey)) ? $this->apiKey."." : null)."{$this->host}\r\n" .
- "Content-Type: application/x-www-form-urlencoded; charset=utf-8\r\n" .
- "Content-Length: ".strlen($request)."\r\n" .
- "User-Agent: Akismet PHP4 Class\r\n" .
- "\r\n" .
- $request
- ;
- $response = "";
-
- @fwrite($this->con, $request);
-
- while(!feof($this->con)) {
- $response .= @fgets($this->con, $responseLength);
- }
-
- $response = explode("\r\n\r\n", $response, 2);
- return $response[1];
- } else {
- $this->setError(AKISMET_RESPONSE_FAILED, "The response could not be retrieved.");
- }
-
- $this->_disconnect();
- }
-
-
- // Connect to the Akismet server and store that connection in the instance variable $con
- function _connect() {
- if(!($this->con = @fsockopen($this->host, $this->port))) {
- $this->setError(AKISMET_SERVER_NOT_FOUND, "Could not connect to akismet server.");
- }
- }
-
-
- // Close the connection to the Akismet server
- function _disconnect() {
- @fclose($this->con);
- }
-
-
-}
-
-
-
-
-
-// The controlling class. This is the ONLY class the user should instantiate in
-// order to use the Akismet service!
-class Akismet extends AkismetObject {
- var $apiPort = 80;
- var $akismetServer = 'rest.akismet.com';
- var $akismetVersion = '1.1';
- var $http;
-
- var $ignore = array(
- 'HTTP_COOKIE',
- 'HTTP_X_FORWARDED_FOR',
- 'HTTP_X_FORWARDED_HOST',
- 'HTTP_MAX_FORWARDS',
- 'HTTP_X_FORWARDED_SERVER',
- 'REDIRECT_STATUS',
- 'SERVER_PORT',
- 'PATH',
- 'DOCUMENT_ROOT',
- 'SERVER_ADMIN',
- 'QUERY_STRING',
- 'PHP_SELF',
- 'argv'
- );
-
- var $blogUrl = "";
- var $apiKey = "";
- var $comment = array();
-
-
- /**
- * Constructor
- *
- * Set instance variables, connect to Akismet, and check API key
- *
- * @param String $blogUrl The URL to your own blog
- * @param String $apiKey Your wordpress API key
- * @param String[] $comment A formatted comment array to be examined by the Akismet service
- * @return Akismet
- */
- function Akismet($blogUrl, $apiKey, $comment = array()) {
- $this->blogUrl = $blogUrl;
- $this->apiKey = $apiKey;
- $this->setComment($comment);
-
- // Connect to the Akismet server and populate errors if they exist
- $this->http = new AkismetHttpClient($this->akismetServer, $blogUrl, $apiKey);
- if($this->http->errorsExist()) {
- $this->errors = array_merge($this->errors, $this->http->getErrors());
- }
-
- // Check if the API key is valid
- if(!$this->_isValidApiKey($apiKey)) {
- $this->setError(AKISMET_INVALID_KEY, "Your Akismet API key is not valid.");
- }
- }
-
-
- /**
- * Query the Akismet and determine if the comment is spam or not
- *
- * @return boolean
- */
- function isSpam() {
- $response = $this->http->getResponse($this->_getQueryString(), 'comment-check');
-
- return ($response == "true");
- }
-
-
- /**
- * Submit this comment as an unchecked spam to the Akismet server
- *
- * @return void
- */
- function submitSpam() {
- $this->http->getResponse($this->_getQueryString(), 'submit-spam');
- }
-
-
- /**
- * Submit a false-positive comment as "ham" to the Akismet server
- *
- * @return void
- */
- function submitHam() {
- $this->http->getResponse($this->_getQueryString(), 'submit-ham');
- }
-
-
- /**
- * Manually set the comment value of the instantiated object.
- *
- * @param Array $comment
- * @return void
- */
- function setComment($comment) {
- $this->comment = $comment;
- if(!empty($comment)) {
- $this->_formatCommentArray();
- $this->_fillCommentValues();
- }
- }
-
-
- /**
- * Returns the current value of the object's comment array.
- *
- * @return Array
- */
- function getComment() {
- return $this->comment;
- }
-
-
- /**
- * Check with the Akismet server to determine if the API key is valid
- *
- * @access Protected
- * @param String $key The Wordpress API key passed from the constructor argument
- * @return boolean
- */
- function _isValidApiKey($key) {
- $keyCheck = $this->http->getResponse("key=".$this->apiKey."&blog=".$this->blogUrl, 'verify-key');
-
- return ($keyCheck == "valid");
- }
-
-
- /**
- * Format the comment array in accordance to the Akismet API
- *
- * @access Protected
- * @return void
- */
- function _formatCommentArray() {
- $format = array(
- 'type' => 'comment_type',
- 'author' => 'comment_author',
- 'email' => 'comment_author_email',
- 'website' => 'comment_author_url',
- 'body' => 'comment_content'
- );
-
- foreach($format as $short => $long) {
- if(isset($this->comment[$short])) {
- $this->comment[$long] = $this->comment[$short];
- unset($this->comment[$short]);
- }
- }
- }
-
-
- /**
- * Fill any values not provided by the developer with available values.
- *
- * @return void
- */
- function _fillCommentValues() {
- if(!isset($this->comment['user_ip'])) {
- $this->comment['user_ip'] = ($_SERVER['REMOTE_ADDR'] != getenv('SERVER_ADDR')) ? $_SERVER['REMOTE_ADDR'] : getenv('HTTP_X_FORWARDED_FOR');
- }
- if(!isset($this->comment['user_agent'])) {
- $this->comment['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
- }
- if(!isset($this->comment['referrer'])) {
- $this->comment['referrer'] = $_SERVER['HTTP_REFERER'];
- }
- if(!isset($this->comment['blog'])) {
- $this->comment['blog'] = $this->blogUrl;
- }
- }
-
-
- /**
- * Build a query string for use with HTTP requests
- *
- * @access Protected
- * @return String
- */
- function _getQueryString() {
- foreach($_SERVER as $key => $value) {
- if(!in_array($key, $this->ignore)) {
- if($key == 'REMOTE_ADDR') {
- $this->comment[$key] = $this->comment['user_ip'];
- } else {
- $this->comment[$key] = $value;
- }
- }
- }
-
- $query_string = '';
-
- foreach($this->comment as $key => $data) {
- $query_string .= $key . '=' . urlencode(stripslashes($data)) . '&';
- }
-
- return $query_string;
- }
-
-
-}
-?>
\ No newline at end of file
+++ /dev/null
-scrypt
-Dominic Black
\ No newline at end of file
+++ /dev/null
-Original Scrypt Implementation;
- Copyright (c) 2009 Colin Percival
-
-PHP Module;
- Copyright (c) 2012, Dominic Black
-
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-
-1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
-
-2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+++ /dev/null
-PHP scrypt module
-=================
-
-[![Build Status](https://travis-ci.org/DomBlack/php-scrypt.svg?branch=master)](https://travis-ci.org/DomBlack/php-scrypt)
-
-This is a PHP library providing a wrapper to [Colin Percival's scrypt implementation](http://www.tarsnap.com/scrypt.html). Scrypt is a key derivation function designed to be far more secure against hardware brute-force attacks than alternative functions such as PBKDF2 or bcrypt.
-
-Details of the scrypt key derivation function are given in a paper by Colin Percival, Stronger Key Derivation via Sequential Memory-Hard Functions: [PDF](http://www.tarsnap.com/scrypt/scrypt-slides.pdf).
-
-An example class using this module can be found in; scrypt.php
-
-Join in!
---------
-
-We are happy to receive bug reports, fixes, documentation enhancements, and other improvements.
-
-Please report bugs via the [github issue tracker](http://github.com/DomBlack/php-scrypt/issues).
-
-Master [git repository](https://github.com/DomBlack/php-scrypt):
-
- git clone git://github.com/DomBlack/php-scrypt.git
-
-Authors
--------
-
-This library is written and maintained by Dominic Black, <thephenix@gmail.com>.
-
-----
-
-PECL Install
-============
-
-This extension is now avaible through PECL.
-
-```
-pecl install scrypt
-```
-
-Build From Source
-=================
-
-Unix/OSX
---------
-
-1. `phpize`
-2. If on OSX; `export CFLAGS='-arch i386 -arch x86_64'`
-3. `./configure --enable-scrypt`
-4. `make`
-5. `make install`
-6. Add the extension to your php.ini
-
-````
- ; Enable scrypt extension module
- extension=scrypt.so
-````
-
-Windows
--------
-
-Using Visual Studio 2008 (or Visual C++ Express 2008) open up the attached project
-inside the VS2008 folder. This project assumes you have the PHP thread safe source at;
-`C:\phpsrcts\`, a PHP install at `C:\php\` and this source code extracted to
-`C:\php-scrypt\`.
-
-1. Build the project.
-2. Copy the resultant `scrypt.dll` to your ext directory in PHP.
-3. Add the extension to your php.ini
-
-````
- ; Enable scrypt extension module
- extension=scrypt.dll
-````
-
-Legal Stuff
-===========
-This works is licensed under the BSD 2-Clause license.
-
-Original Scrypt Implementation;
- Copyright (c) 2009 Colin Percival
-
-PHP Module;
- Copyright (c) 2012, Dominic Black
-
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-
-Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
-Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*/
public static final function exitApplication (string $message = '', int $code = -1, string $extraData = '', bool $silentMode = false) {
// Is this method already called?
+ //* NOISY-DEBUG: */ printf('[%s:%d]: message=%s,code=%d,extraData=%s,silentMode=%d - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $message, $code, $extraData, intval($silentMode));
if (isset($GLOBALS['app_die_called'])) {
// Then output the text directly
- exit($message);
+ print $message . PHP_EOL;
+ exit(255);
}
// This method shall not be called twice
// Do we have debug installation?
if (($configInstance->getConfigEntry('product_install_mode') == 'productive') || ($silentMode === true)) {
// Abort here
- exit;
+ //* NOISY-DEBUG: */ printf('[%s:%d]: product_install_mode=%d,silentMode=%d - EXIT!' . PHP_EOL, __METHOD__, __LINE__, $configInstance->getConfigEntry('product_install_mode'), intval($silentMode));
+ exit(255);
}
// Get some instances
$responseInstance->flushBuffer();
} catch (FileNotFoundException $e) {
// Even the template 'emergency_exit' wasn't found so output both message
- exit($message . ', exception: ' . $e->getMessage());
+ print ($message . ', exception: ' . $e->getMessage() . PHP_EOL);
+ exit($e->getCode());
}
// Good bye...
- exit;
+ exit(255);
} else {
// Output message and die
- die(sprintf('[Main:] Emergency exit reached: <span class="emergency_span">%s</span>',
- $message
- ));
+ printf('[Main:] Emergency exit reached: <span class="emergency_span">%s</span>', $message);
+ exit(255);
}
+
+ // Trace message
+ //* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__);
}
/**
*/
public static final function detectFrameworkPath () {
// Is it not set?
+ //* NOISY-DEBUG: */ printf('[%s:%d]: self::frameworkPath=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, self::$frameworkPath);
if (empty(self::$frameworkPath)) {
// Auto-detect core path (first application-common)
- foreach (array('core', __DIR__, '/usr/local/share/php/core', '/usr/share/php/core') as $possiblePath) {
+ foreach (['core', self::getRootPath(), '/usr/local/share/php/core', '/usr/share/php/core'] as $possiblePath) {
// Create full path for testing
+ //* NOISY-DEBUG: */ printf('[%s:%d]: possiblePath=%s' . PHP_EOL, __METHOD__, __LINE__, $possiblePath);
$realPath = realpath($possiblePath);
// Is it false?
//* NOISY-DEBUG: */ printf('[%s:%d]: realPath[%s]=%s' . PHP_EOL, __METHOD__, __LINE__, gettype($realPath), $realPath);
if ($realPath === false) {
// Then, not found.
+ //* NOISY-DEBUG: */ printf('[%s:%d]: possiblePath=%s was not found. - SKIPPED!' . PHP_EOL, __METHOD__, __LINE__, $possiblePath);
continue;
}
$frameworkPath = sprintf('%s%sframework%s', $realPath, DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR);
// First create full-qualified file name (FQFN) to framework/config-global.php
+ //* NOISY-DEBUG: */ printf('[%s:%d]: frameworkPath=%s' . PHP_EOL, __METHOD__, __LINE__, $frameworkPath);
$configFile = $frameworkPath . 'config-global.php';
// Is it readable?
self::$frameworkPath = $frameworkPath;
// Abort here
+ //* NOISY-DEBUG: */ printf('[%s:%d]: Setting self::frameworkPath=%s - BREAK!' . PHP_EOL, __METHOD__, __LINE__, $frameworkPath);
break;
}
}
// Able to find?
+ //* NOISY-DEBUG: */ printf('[%s:%d]: self::frameworkPath=%s - Checking ...' . PHP_EOL, __METHOD__, __LINE__, self::$frameworkPath);
if (!is_dir(self::$frameworkPath)) {
// Is no directory
throw new Exception('Cannot find framework.');
}
// Return it
+ //* NOISY-DEBUG: */ printf('[%s:%d]: self::frameworkPath=%s - EXIT!' . PHP_EOL, __METHOD__, __LINE__, self::$frameworkPath);
return self::$frameworkPath;
}
*/
public static final function main () {
// Load bootstrap file
+ //* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__);
require sprintf('%sbootstrap%sbootstrap.inc.php', self::detectFrameworkPath(), DIRECTORY_SEPARATOR);
/*
* register the application instance in registry.
*/
FrameworkBootstrap::startApplication();
+
+ // Trace message
+ //* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__);
}
}
// Log all exceptions (only debug! This option can create large error logs)
//define('LOG_EXCEPTIONS', true);
-//xdebug_start_trace();
-
// Call above main() method
ApplicationEntryPoint::main();
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
/*
- * Copyright (C) 2017 - 2022 Core Developer Team
+ * Copyright (C) 2017 - 2023 Core Developer Team
*
* 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
require dirname(__DIR__) . '/vendor/autoload.php';
// Quiet DNS resolver as this is not wanted here
-FrameworkBootstrap::getConfigurationInstance()->setConfigEntry('quiet_dns_resolver', TRUE);
+FrameworkBootstrap::getConfigurationInstance()->setConfigEntry('is_quiet_dns_resolver_enabled', TRUE);
use Org\Mxchange\CoreFramework\Console\Tools\ConsoleTools;
use Org\Mxchange\CoreFramework\Generic\NullPointerException;
use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
+use Org\Mxchange\CoreFramework\Loader\ClassLoader;
// Import PHPUnit stuff
use PHPUnit\Framework\Error\Notice;
// Import SPL stuff
use \InvalidArgumentException;
+use \SplFileInfo;
/*
- * Copyright (C) 2017 - 2022 Core Developer Team
+ * Copyright (C) 2017 - 2023 Core Developer Team
*
* 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
/**
* Own IP address
*/
- private static $ipAddress = FALSE;
+ private static $ipAddress = '0.0.0.0';
+
+ /**
+ * Own host name
+ */
+ private static $hostname = 'host.invalid';
/**
* Setup test case
// Trace message
//* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__);
-
}
/**
* Setup test case
*/
public static function setUpBeforeClass() {
- // Trace message
- //* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__);
-
// Call parent method
+ //* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__);
parent::setUpBeforeClass();
+ // Lookup own hostname
+ self::$hostname = ConsoleTools::acquireHostname();
+
// Lookup own IP address
self::$ipAddress = ConsoleTools::acquireSelfIpAddress();
// Trace message
- //* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__);
+ //* NOISY-DEBUG: */ printf('[%s:%d]: self::ipAddress[%s]=%s,self::hostname=%s - EXIT!' . PHP_EOL, __METHOD__, __LINE__, gettype(self::$ipAddress), self::$ipAddress, self::$hostname);
}
/**
* Tests if detectServerAddress() is returning what it should for tests.
* This will always be 127.0.0.1.
*/
- public function testConfigDetectServerAddress () {
+ public function testBootstrapDetectServerAddress () {
// Call it
$serverAddress = FrameworkBootstrap::detectServerAddress();
* This will always be 127.0.0.1. This method should not invoke
* ConsoleTools's method as the configuration entry is already cached.
*/
- public function testConfigDetectServerAddressCached () {
+ public function testBootstrapDetectServerAddressCached () {
// Call it
+ //* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__);
$serverAddress = FrameworkBootstrap::detectServerAddress();
// Should be the same
+ //* NOISY-DEBUG: */ printf('[%s:%d]: self::ipAddress=%s,serverAddress=%s' . PHP_EOL, __METHOD__, __LINE__, self::$ipAddress, $serverAddress);
$this->assertEquals(self::$ipAddress, $serverAddress);
+
+ // Trace message
+ //* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__);
+ }
+
+ /**
+ * Tests method BootstrapFramework::isReachableFilePath() with a
+ * non-existing path. $isReachable should always return TRUE as nothing is
+ * restricting PHP.
+ */
+ public function testBootstrapIsReachableFilePathUnrestrictedNotExisting () {
+ // Init SPL file info instance
+ //* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__);
+ $infoInstance = new SplFileInfo('/does/not/exist/');
+
+ // Invoke method
+ //* NOISY-DEBUG: */ printf('[%s:%d]: infoInstance=%s' . PHP_EOL, __METHOD__, __LINE__, get_class($infoInstance));
+ $isReachable = FrameworkBootstrap::isReachableFilePath($infoInstance);
+
+ // Test if it is not reachable
+ //* NOISY-DEBUG: */ printf('[%s:%d]: isReachable=%d' . PHP_EOL, __METHOD__, __LINE__, intval($isReachable));
+ $this->assertTrue($isReachable, 'Returned true on a non-existing path');
+
+ // Trace message
+ //* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__);
+ }
+
+ /**
+ * Tests method BootstrapFramework::isReachableFilePath() with a
+ * non-existing path. $isReachable should be FALSE here as it is always
+ * outside the scope of open_basedir.
+ */
+ public function testBootstrapIsReachableFilePathRestrictedNotExisting () {
+ // Init SPL file info instance
+ //* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__);
+ $infoInstance = new SplFileInfo('/does/not/exist/');
+
+ // "Detect" root path
+ //* NOISY-DEBUG: */ printf('[%s:%d]: infoInstance=%s' . PHP_EOL, __METHOD__, __LINE__, get_class($infoInstance));
+ $rootScriptPath = realpath(dirname(dirname(FrameworkBootstrap::detectScriptPath())));
+
+ // Set it
+ //* NOISY-DEBUG: */ printf('[%s:%d]: open_basedir=%s,rootScriptPath[%s]=%s' . PHP_EOL, __METHOD__, __LINE__, ini_get('open_basedir'), gettype($rootScriptPath), $rootScriptPath);
+ $result = ini_set('open_basedir', $rootScriptPath . ':/etc/');
+
+ // Was it set?
+ //* NOISY-DEBUG: */ printf('[%s:%d]: result[]=%s' . PHP_EOL, __METHOD__, __LINE__, gettype($result));
+ if ($result === FALSE) {
+ // Didn't work
+ $this->failed(sprintf('Cannot set open_basepath=%s', $rootScriptPath));
+ }
+
+ // Invoke method
+ //* NOISY-DEBUG: */ printf('[%s:%d]: Testing method FrameworkBootstrap::isReachableFilePath(%s) ...' . PHP_EOL, __METHOD__, __LINE__, get_class($infoInstance));
+ $isReachable = FrameworkBootstrap::isReachableFilePath($infoInstance);
+
+ // Test if
+ //* NOISY-DEBUG: */ printf('[%s:%d]: isReachable=%d - Testing method ...' . PHP_EOL, __METHOD__, __LINE__, intval($isReachable));
+ $this->assertTrue(!$isReachable, 'Returned true on a non-existing path');
+
+ // Trace message
+ //* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__);
+ }
+
+ /**
+ * Tests method BootstrapFramework::isReachableFilePath() with an
+ * existing path. $isReachable should be TRUE here as it is within the scope
+ * of open_basedir.
+ */
+ public function testBootstrapIsReachableFilePathRestrictedExisting () {
+ // Init SPL file info instance
+ //* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__);
+ $infoInstance = new SplFileInfo(__DIR__);
+
+ // "Detect" root path
+ //* NOISY-DEBUG: */ printf('[%s:%d]: infoInstance=%s' . PHP_EOL, __METHOD__, __LINE__, get_class($infoInstance));
+ $rootScriptPath = realpath(dirname(dirname(FrameworkBootstrap::detectScriptPath())));
+
+ // Set it
+ //* NOISY-DEBUG: */ printf('[%s:%d]: rootScriptPath[%s]=%s' . PHP_EOL, __METHOD__, __LINE__, gettype($rootScriptPath), $rootScriptPath);
+ $result = ini_set('open_basedir', $rootScriptPath . ':/etc/');
+
+ // Was it set?
+ //* NOISY-DEBUG: */ printf('[%s:%d]: result[]=%s' . PHP_EOL, __METHOD__, __LINE__, gettype($result));
+ if ($result === FALSE) {
+ // Didn't work
+ $this->failed(sprintf('Cannot set open_basepath=%s', $rootScriptPath));
+ }
+
+ // Invoke method
+ //* NOISY-DEBUG: */ printf('[%s:%d]: Testing method FrameworkBootstrap::isReachableFilePath(%s) ...' . PHP_EOL, __METHOD__, __LINE__, get_class($infoInstance));
+ $isReachable = FrameworkBootstrap::isReachableFilePath($infoInstance);
+
+ // Test if
+ //* NOISY-DEBUG: */ printf('[%s:%d]: isReachable=%d - Testing method ...' . PHP_EOL, __METHOD__, __LINE__, intval($isReachable));
+ $this->assertTrue($isReachable, 'Returned true on a non-existing path');
+
+ // Trace message
+ //* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__);
}
}
// Import SPL stuff
use \InvalidArgumentException;
+use \UnexpectedValueException;
/*
* Copyright (C) 2017 - 2020 - Core Developer Team
$dummy = self::$configInstance->isFieldSet('foo');
}
+ /**
+ * Tests isEnabled() method being called with empty parameter
+ */
+ public function testConfigIsEnabledEmptyString () {
+ // Expect IAE
+ $this->expectException(InvalidArgumentException::class);
+
+ // Just invoke it
+ $dummy = self::$configInstance->isEnabled('');
+ }
+
+ /**
+ * Tests isEnabled() method being called with missing configuration key
+ */
+ public function testConfigIsEnabledMissingConfigKey () {
+ // Expect NoConfig
+ $this->expectException(NoConfigEntryException::class);
+
+ // Just invoke it
+ $dummy = self::$configInstance->isEnabled('does_not_exist');
+ }
+
+ /**
+ * Tests isEnabled() method being called with non-boolean configuration key
+ */
+ public function testConfigIsEnabledNonBooleanConfigKey () {
+ // Expect UVE
+ $this->expectException(UnexpectedValueException::class);
+
+ // Set it temporary
+ self::$configInstance->setConfigEntry('is_non_boolean_enabled', 'Y');
+
+ // Just invoke it
+ $dummy = self::$configInstance->isEnabled('non_boolean');
+ }
+
+ /**
+ * Tests isEnabled() method being called with 'single_server'
+ */
+ public function testConfigIsEnabledSingleServerConfigKey () {
+ // Check it on known boolean value
+ $this->assertTrue(is_bool(self::$configInstance->isEnabled('single_server')));
+ }
+
+ /**
+ * Tests if sorting the configuration array is always returning the same
+ * array (but sorted) back.
+ */
+ public function testConfigSortConfigurationArray () {
+ // First get configuration array
+ //* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__);
+ $config = self::$configInstance->getConfigurationArray();
+
+ // Run sort method
+ //* NOISY-DEBUG: */ printf('[%s:%d]: config()=%d' . PHP_EOL, __METHOD__, __LINE__, count($config));
+ self::$configInstance->sortConfigurationArray();
+
+ // This should be an empty array
+ $diff = array_diff($config, self::$configInstance->getConfigurationArray());
+
+ // Check condition
+ //* NOISY-DEBUG: */ printf('[%s:%d]: diff()=%d' . PHP_EOL, __METHOD__, __LINE__, count($diff));
+ $this->assertTrue(count($diff) === 0);
+
+ // Trace message
+ //* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__);
+ }
+
}