]> git.mxchange.org Git - core.git/commitdiff
Refacuring:
authorRoland Häder <roland@mxchange.org>
Wed, 2 Dec 2020 05:16:36 +0000 (06:16 +0100)
committerRoland Häder <roland@mxchange.org>
Wed, 2 Dec 2020 05:25:23 +0000 (06:25 +0100)
- removed CacheFactory, is already reduced to what
  ObjectFactory::createObjectByConfiguredName() does
- external $cache, $compressorChannel and $ioHandler as traits
- added type-hints for primitive variables

Signed-off-by: Roland Häder <roland@mxchange.org>
16 files changed:
framework/main/classes/application/class_BaseApplication.php
framework/main/classes/class_BaseFrameworkSystem.php
framework/main/classes/class_FrameworkArrayObject.php
framework/main/classes/database/backend/lfdb_legacy/class_CachedLocalFileDatabase.php
framework/main/classes/database/frontend/class_BaseDatabaseFrontend.php
framework/main/classes/factories/cache/class_CacheFactory.php [deleted file]
framework/main/classes/file_directories/class_BaseFileIo.php
framework/main/classes/filter/verifier/class_GraphicalCodeCaptchaVerifierFilter.php
framework/main/classes/template/class_BaseTemplateEngine.php
framework/main/exceptions/class_FrameworkException.php
framework/main/interfaces/database/frontend/class_DatabaseFrontend.php
framework/main/interfaces/database/middleware/class_DatabaseConnector.php
framework/main/middleware/database/class_DatabaseConnection.php
framework/main/traits/cache/class_CacheableTrait.php [new file with mode: 0644]
framework/main/traits/compressor/class_CompressorChannelTrait.php [new file with mode: 0644]
framework/main/traits/handler/io/class_IoHandlerTrait.php [new file with mode: 0644]

index fe844a21dae06bd8602bd7cecf5d70caaa6e83dc..bdf05189bac338848ee7ef9c62a65d6b9862533e 100644 (file)
@@ -164,7 +164,7 @@ abstract class BaseApplication extends BaseFrameworkSystem {
         */
        public final function setAppShortName (string $shortName) {
                // Cast and set it
-               $this->shortName = (string) $shortName;
+               $this->shortName = $shortName;
        }
 
 }
index 43146fc0ed40eb52a157c56e72bc6ff0986d2731..274fb7d62f097c5ed7d8e1597d22444c722645ce 100644 (file)
@@ -481,7 +481,7 @@ abstract class BaseFrameworkSystem extends stdClass implements FrameworkInterfac
         * @param       $str    A string (maybe) without trailing slash
         * @return      $str    A string with an auto-appended trailing slash
         */
-       public final function addMissingTrailingSlash ($str) {
+       public final function addMissingTrailingSlash (string $str) {
                // Is there a trailing slash?
                if (substr($str, -1, 1) != '/') {
                        $str .= '/';
@@ -1053,7 +1053,7 @@ Loaded includes:
         * @param       $element        Element to check
         * @return      $isset          Whether the given key is set
         */
-       protected final function isGenericArrayElementSet ($keyGroup, $subGroup, $key, $element) {
+       protected final function isGenericArrayElementSet (string $keyGroup, string $subGroup, $key, $element) {
                // Debug message
                //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element);
 
@@ -1071,7 +1071,7 @@ Loaded includes:
         * @param       $key            Key to check
         * @return      $isset          Whether the given key is set
         */
-       protected final function isGenericArrayKeySet ($keyGroup, $subGroup, $key) {
+       protected final function isGenericArrayKeySet (string $keyGroup, string $subGroup, $key) {
                // Debug message
                //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key);
 
@@ -1090,7 +1090,7 @@ Loaded includes:
         * @param       $subGroup       Sub group
         * @return      $isset          Whether the given group is set
         */
-       protected final function isGenericArrayGroupSet ($keyGroup, $subGroup) {
+       protected final function isGenericArrayGroupSet (string $keyGroup, string $subGroup) {
                // Debug message
                //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup);
 
@@ -1108,7 +1108,7 @@ Loaded includes:
         * @param       $subGroup       Sub key group
         * @return      $array          An array with all array elements
         */
-       protected final function getGenericSubArray ($keyGroup, $subGroup) {
+       protected final function getGenericSubArray (string $keyGroup, string $subGroup) {
                // Is it there?
                if (!$this->isGenericArrayGroupSet($keyGroup, $subGroup)) {
                        // No, then abort here
@@ -1131,7 +1131,7 @@ Loaded includes:
         * @param       $key            Key to unset
         * @return      void
         */
-       protected final function unsetGenericArrayKey ($keyGroup, $subGroup, $key) {
+       protected final function unsetGenericArrayKey (string $keyGroup, string $subGroup, $key) {
                // Debug message
                //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key);
 
@@ -1148,7 +1148,7 @@ Loaded includes:
         * @param       $element        Element to unset
         * @return      void
         */
-       protected final function unsetGenericArrayElement ($keyGroup, $subGroup, $key, $element) {
+       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);
 
@@ -1165,7 +1165,7 @@ Loaded includes:
         * @param       $value          Value to add/append
         * @return      void
         */
-       protected final function appendStringToGenericArrayKey ($keyGroup, $subGroup, $key, $value, $appendGlue = '') {
+       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);
 
@@ -1189,7 +1189,7 @@ Loaded includes:
         * @param       $value          Value to add/append
         * @return      void
         */
-       protected final function appendStringToGenericArrayElement ($keyGroup, $subGroup, $key, $element, $value, $appendGlue = '') {
+       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);
 
@@ -1213,7 +1213,7 @@ Loaded includes:
         * @param       $value          Value to add/append
         * @return      void
         */
-       protected final function setStringGenericArrayElement ($keyGroup, $subGroup, $key, $element, $value, $appendGlue = '') {
+       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);
 
@@ -1230,7 +1230,7 @@ Loaded includes:
         * @param       $forceInit      Optionally force initialization
         * @return      void
         */
-       protected final function initGenericArrayGroup ($keyGroup, $subGroup, $forceInit = false) {
+       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));
 
@@ -1254,7 +1254,7 @@ Loaded includes:
         * @param       $forceInit      Optionally force initialization
         * @return      void
         */
-       protected final function initGenericArrayKey ($keyGroup, $subGroup, $key, $forceInit = false) {
+       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));
 
@@ -1279,7 +1279,7 @@ Loaded includes:
         * @param       $forceInit      Optionally force initialization
         * @return      void
         */
-       protected final function initGenericArrayElement ($keyGroup, $subGroup, $key, $element, $forceInit = false) {
+       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));
 
@@ -1303,7 +1303,7 @@ Loaded includes:
         * @param       $value          Value to add/append
         * @return      $count          Number of array elements
         */
-       protected final function pushValueToGenericArrayKey ($keyGroup, $subGroup, $key, $value) {
+       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));
 
@@ -1332,7 +1332,7 @@ Loaded includes:
         * @param       $value          Value to add/append
         * @return      $count          Number of array elements
         */
-       protected final function pushValueToGenericArrayElement ($keyGroup, $subGroup, $key, $element, $value) {
+       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));
 
@@ -1359,7 +1359,7 @@ Loaded includes:
         * @param       $key            Key to unset
         * @return      $value          Last "popped" value
         */
-       protected final function popGenericArrayElement ($keyGroup, $subGroup, $key) {
+       protected final function popGenericArrayElement (string $keyGroup, string $subGroup, $key) {
                // Debug message
                //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key);
 
@@ -1387,7 +1387,7 @@ Loaded includes:
         * @param       $key            Key to unset
         * @return      $value          Last "popped" value
         */
-       protected final function shiftGenericArrayElement ($keyGroup, $subGroup, $key) {
+       protected final function shiftGenericArrayElement (string $keyGroup, string $subGroup, $key) {
                // Debug message
                //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key);
 
@@ -1441,7 +1441,7 @@ Loaded includes:
         * @param       $subGroup       Sub group for the key
         * @return      $count          Count of given group
         */
-       protected final function countGenericArrayGroup ($keyGroup, $subGroup) {
+       protected final function countGenericArrayGroup (string $keyGroup, string $subGroup) {
                // Debug message
                //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup);
 
@@ -1470,7 +1470,7 @@ Loaded includes:
         * @para        $key            Key to count
         * @return      $count          Count of given key
         */
-       protected final function countGenericArrayElements ($keyGroup, $subGroup, $key) {
+       protected final function countGenericArrayElements (string $keyGroup, string $subGroup, $key) {
                // Debug message
                //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key);
 
@@ -1525,7 +1525,7 @@ Loaded includes:
         * @param       $value          Mixed value from generic array element
         * @return      void
         */
-       protected final function setGenericArrayKey ($keyGroup, $subGroup, $key, $value) {
+       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));
 
@@ -1541,7 +1541,7 @@ Loaded includes:
         * @param       $key            Key to unset
         * @return      $value          Mixed value from generic array element
         */
-       protected final function getGenericArrayKey ($keyGroup, $subGroup, $key) {
+       protected final function getGenericArrayKey (string $keyGroup, string $subGroup, $key) {
                // Debug message
                //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key);
 
@@ -1566,7 +1566,7 @@ Loaded includes:
         * @param       $value          Value to set
         * @return      void
         */
-       protected final function setGenericArrayElement ($keyGroup, $subGroup, $key, $element, $value) {
+       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));
 
@@ -1583,7 +1583,7 @@ Loaded includes:
         * @param       $element        Element to look for
         * @return      $value          Mixed value from generic array element
         */
-       protected final function getGenericArrayElement ($keyGroup, $subGroup, $key, $element) {
+       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);
 
@@ -1605,7 +1605,7 @@ Loaded includes:
         * @param       $subGroup       Sub group for the key
         * @return      $isValid        Whether given sub group is valid
         */
-       protected final function isValidGenericArrayGroup ($keyGroup, $subGroup) {
+       protected final function isValidGenericArrayGroup (string $keyGroup, string $subGroup) {
                // Debug message
                //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup);
 
@@ -1624,7 +1624,7 @@ Loaded includes:
         * @param       $key            Key to check
         * @return      $isValid        Whether given sub group is valid
         */
-       protected final function isValidGenericArrayKey ($keyGroup, $subGroup, $key) {
+       protected final function isValidGenericArrayKey (string $keyGroup, string $subGroup, $key) {
                // Debug message
                //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key);
 
index 11b896a4064966ade770c910e5d553dd96b258b7..2a861e9654438cf67d096b126d3d7873c1856998 100644 (file)
@@ -41,7 +41,7 @@ class FrameworkArrayObject extends ArrayObject {
         * @param       $className      Real class name
         */
        public function __construct (string $className) {
-               $this->realClass = (string) $className;
+               $this->realClass = $className;
        }
 
        /**
index d79963d70c41329ebafd6f784d64f462f695fa07..37426c86d83891a0d974dc2706eb4ce4272617d7 100644 (file)
@@ -12,8 +12,8 @@ use Org\Mxchange\CoreFramework\Database\Backend\DatabaseBackend;
 use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
 use Org\Mxchange\CoreFramework\Filesystem\FileNotFoundException;
 use Org\Mxchange\CoreFramework\Generic\FrameworkException;
-use Org\Mxchange\CoreFramework\Handler\Stream\IoHandler;
-use Org\Mxchange\CoreFramework\Middleware\Compressor\CompressorChannel;
+use Org\Mxchange\CoreFramework\Traits\Compressor\Channel\CompressorChannelTrait;
+use Org\Mxchange\CoreFramework\Traits\Handler\Io\IoHandlerTrait;
 
 // Import SPL stuff
 use \SplFileInfo;
@@ -47,6 +47,10 @@ use \SplFileInfo;
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 class CachedLocalFileDatabase extends BaseDatabaseBackend implements DatabaseBackend {
+       // Load traits
+       use CompressorChannelTrait;
+       use IoHandlerTrait;
+
        /**
         * The file's extension
         */
@@ -77,16 +81,6 @@ class CachedLocalFileDatabase extends BaseDatabaseBackend implements DatabaseBac
         */
        private $indexKey = '__idx';
 
-       /**
-        * The file I/O instance for the template loader
-        */
-       private $fileIoInstance = NULL;
-
-       /**
-        * A Compressor instance
-        */
-       private $compressorChannelInstance = NULL;
-
        /**
         * The protected constructor. Do never instance from outside! You need to
         * set a local file path. The class will then validate it.
@@ -108,17 +102,11 @@ class CachedLocalFileDatabase extends BaseDatabaseBackend implements DatabaseBac
                // Get an instance
                $databaseInstance = new CachedLocalFileDatabase();
 
-               // Get a new compressor channel instance
-               $compressorChannelInstance = ObjectFactory::createObjectByConfiguredName('compressor_channel_class');
-
                // Set the compressor channel
-               $databaseInstance->setCompressorChannelInstance($compressorChannelInstance);
+               $databaseInstance->setCompressorChannelInstance(ObjectFactory::createObjectByConfiguredName('compressor_channel_class'));
 
-               // Get a file IO handler
-               $fileIoInstance = ObjectFactory::createObjectByConfiguredName('file_io_class');
-
-               // ... and set it
-               $databaseInstance->setFileIoInstance($fileIoInstance);
+               // Get a file IO handler and set it
+               $databaseInstance->setFileIoInstance(ObjectFactory::createObjectByConfiguredName('file_io_class'));
 
                // "Connect" to the database
                $databaseInstance->connectToDatabase();
@@ -184,43 +172,6 @@ class CachedLocalFileDatabase extends BaseDatabaseBackend implements DatabaseBac
        public final function getIndexKey () {
                return $this->indexKey;
        }
-       /**
-        * Private getter for file IO instance
-        *
-        * @return      $fileIoInstance         An instance to the file I/O sub-system
-        */
-       protected final function getFileIoInstance () {
-               return $this->fileIoInstance;
-       }
-
-       /**
-        * Setter for file I/O instance
-        *
-        * @param       $fileIoInstance         An instance to the file I/O sub-system
-        * @return      void
-        */
-       public final function setFileIoInstance (IoHandler $fileIoInstance) {
-               $this->fileIoInstance = $fileIoInstance;
-       }
-
-       /**
-        * Setter for compressor channel
-        *
-        * @param       $compressorChannelInstance      An instance of a CompressorChannel class
-        * @return      void
-        */
-       protected final function setCompressorChannelInstance (CompressorChannel $compressorChannelInstance) {
-               $this->compressorChannelInstance = $compressorChannelInstance;
-       }
-
-       /**
-        * Getter for compressor channel
-        *
-        * @return      $compressorChannelInstance      An instance of a CompressorChannel class
-        */
-       protected final function getCompressorChannelInstance () {
-               return $this->compressorChannelInstance;
-       }
 
        /**
         * Reads a local data file  and returns it's contents in an array
index 0a5aba8d77490d4645449f0d5e9f9b400c27b0db..a555e956a139cc19250859e3934673e584713eb4 100644 (file)
@@ -9,6 +9,7 @@ use Org\Mxchange\CoreFramework\Criteria\Storing\StoreableCriteria;
 use Org\Mxchange\CoreFramework\Database\Backend\BaseDatabaseBackend;
 use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
 use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
+use Org\Mxchange\CoreFramework\Traits\Cache\CacheableTrait;
 
 /**
  * A generic database frontend
@@ -33,10 +34,8 @@ use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 abstract class BaseDatabaseFrontend extends BaseFrameworkSystem {
-       /**
-        * Cache instance
-        */
-       private $cacheInstance = NULL;
+       // Load traits
+       use CacheableTrait;
 
        /**
         * Current table name to use
@@ -65,7 +64,7 @@ abstract class BaseDatabaseFrontend extends BaseFrameworkSystem {
                // Is the cache enabled?
                if (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('database_cache_enabled') === true) {
                        // Set the new instance
-                       $this->cacheInstance = CacheFactory::getFactory()->createConfiguredCache();
+                       $this->setCacheInstance(ObjectFactory::createObjectByConfiguredName('cache_class'));
                } // END - if
        }
 
@@ -75,8 +74,8 @@ abstract class BaseDatabaseFrontend extends BaseFrameworkSystem {
         * @param       $tableName      Name of table name to set
         * @return      void
         */
-       protected final function setTableName ($tableName) {
-               $this->tableName = (string) $tableName;
+       protected final function setTableName (string $tableName) {
+               $this->tableName = $tableName;
        }
 
        /**
@@ -109,10 +108,10 @@ abstract class BaseDatabaseFrontend extends BaseFrameworkSystem {
 
                // Does this key exists in cache?
                //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-WRAPPER: cacheKey[%s]=%s', gettype($cacheKey), $cacheKey));
-               if ((FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('database_cache_enabled') === true) && ($this->cacheInstance->offsetExists($cacheKey))) {
+               if ((FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('database_cache_enabled') === true) && ($this->getCacheInstance()->offsetExists($cacheKey))) {
                        // Purge the cache
                        //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-WRAPPER: Calling this->cacheInstance->purgeOffset(%s) ...', $cacheKey));
-                       $this->cacheInstance->purgeOffset($cacheKey);
+                       $this->getCacheInstance()->purgeOffset($cacheKey);
                } // END - if
 
                // Handle it over to the middleware
@@ -141,9 +140,9 @@ abstract class BaseDatabaseFrontend extends BaseFrameworkSystem {
                } // END - if
 
                // Does this key exists in cache?
-               if ((FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('database_cache_enabled') === true) && ($this->cacheInstance->offsetExists($cacheKey))) {
+               if ((FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('database_cache_enabled') === true) && ($this->getCacheInstance()->offsetExists($cacheKey))) {
                        // Purge the cache
-                       $this->cacheInstance->purgeOffset($cacheKey);
+                       $this->getCacheInstance()->purgeOffset($cacheKey);
                } // END - if
 
                // Handle it over to the middleware
@@ -190,10 +189,10 @@ abstract class BaseDatabaseFrontend extends BaseFrameworkSystem {
 
                // Does this key exists in cache?
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-WRAPPER: cacheKey[%s]=%s', gettype($cacheKey), $cacheKey));
-               if ((FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('database_cache_enabled') === true) && ($this->cacheInstance->offsetExists($cacheKey, BaseDatabaseBackend::RESULT_INDEX_ROWS, 1))) {
+               if ((FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('database_cache_enabled') === true) && ($this->getCacheInstance()->offsetExists($cacheKey, BaseDatabaseBackend::RESULT_INDEX_ROWS, 1))) {
                        // Then use this result
                        //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-WRAPPER: Cache used for cacheKey=%s', $cacheKey));
-                       $result = $this->cacheInstance->offsetGet($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-WRAPPER: Quering database, cacheKey=%s ...', $cacheKey));
@@ -206,7 +205,7 @@ abstract class BaseDatabaseFrontend extends BaseFrameworkSystem {
                                if (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('database_cache_enabled') === true) {
                                        // A valid result has returned from the database layer
                                        //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-WRAPPER: Setting cacheKey=%s with result()=%d entries', $cacheKey, count($result)));
-                                       $this->cacheInstance->offsetSet($cacheKey, $result);
+                                       $this->getCacheInstance()->offsetSet($cacheKey, $result);
                                } // END - if
                        } else {
                                // This invalid result must be wrapped
diff --git a/framework/main/classes/factories/cache/class_CacheFactory.php b/framework/main/classes/factories/cache/class_CacheFactory.php
deleted file mode 100644 (file)
index 45877c4..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-<?php
-// Own namespace
-namespace Org\Mxchange\CoreFramework\Factory\Cache;
-
-// Import framework stuff
-use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
-use Org\Mxchange\CoreFramework\Factory\BaseFactory;
-use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
-
-/**
- * A cache factory
- *
- * @author             Roland Haeder <webmaster@shipsimu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.shipsimu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class CacheFactory extends BaseFactory {
-       /**
-        * Singleton instance
-        */
-       private static $selfInstance = NULL;
-
-       /**
-        * Protected constructor
-        *
-        * @return      void
-        */
-       protected function __construct () {
-               // Call parent constructor
-               parent::__construct(__CLASS__);
-       }
-
-       /**
-        * Singleton getter for this class
-        *
-        * @return      $selfInstance   An instance of this class
-        */
-       public static final function getFactory () {
-               // Is the instance null?
-               if (is_null(self::$selfInstance)) {
-                       // Set a new one
-                       self::$selfInstance = new CacheFactory();
-               } // END - if
-
-               // Return the instance
-               return self::$selfInstance;
-       }
-
-       /**
-        * Creates a configured cache instance
-        *
-        * @return      $cacheInstance  An instance of the configured cache
-        */
-       public function createConfiguredCache () {
-               // Read the config entry
-               $cacheType = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('cache_class');
-
-               // And get a new instance
-               $cacheInstance = ObjectFactory::createObjectByName($cacheType);
-
-               // Return the instance
-               return $cacheInstance;
-       }
-
-}
index bda041bb979d44267a85b10e03d43451f9bb9301..6e95edd04298a683e1f6d1606c1481ff65651c9c 100644 (file)
@@ -175,7 +175,7 @@ abstract class BaseFileIo extends BaseFrameworkSystem implements FilePointer, Cl
                $seekStatus = $this->seek(0, SEEK_END);
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d:] seekStatus=%d', __METHOD__, __LINE__, $seekStatus));
 
-               // Get position again  (which is the end of the file)
+               // Get position again (which is the end of the file)
                $size = $this->determineSeekPosition();
 
                // Reset seek position to old
index b88f4bb98a5833d79a004dcfea90720c5e8194ad..52f2da75398a8143c35a7febf5fb365b464233fd 100644 (file)
@@ -67,7 +67,7 @@ class GraphicalCodeCaptchaVerifierFilter extends BaseFilter implements Filterabl
         */
        public function execute (Requestable $requestInstance, Responseable $responseInstance) {
                // Is the form set?
-               if (($requestInstance->getRequestElement('command') !== 'do_form') ||  (!$requestInstance->isRequestElementSet('form'))) {
+               if (($requestInstance->getRequestElement('command') !== 'do_form') || (!$requestInstance->isRequestElementSet('form'))) {
                        // Required field not set
                        $requestInstance->requestIsValid(false);
 
index 05f39746b38f8c9f62244cfa3ebc6076d0d90de3..9209305fab3e97c4e0c4c1dadbb6bb891efa4f9a 100644 (file)
@@ -6,7 +6,6 @@ namespace Org\Mxchange\CoreFramework\Template\Engine;
 use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
 use Org\Mxchange\CoreFramework\EntryPoint\ApplicationEntryPoint;
 use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
-use Org\Mxchange\CoreFramework\Handler\Stream\IoHandler;
 use Org\Mxchange\CoreFramework\Filesystem\FileNotFoundException;
 use Org\Mxchange\CoreFramework\Generic\NullPointerException;
 use Org\Mxchange\CoreFramework\Manager\ManageableApplication;
@@ -14,6 +13,7 @@ use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
 use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
 use Org\Mxchange\CoreFramework\Response\Responseable;
 use Org\Mxchange\CoreFramework\Stacker\Stackable;
+use Org\Mxchange\CoreFramework\Traits\Handler\Io\IoHandlerTrait;
 use Org\Mxchange\CoreFramework\Utils\String\StringUtils;
 
 // Import SPL stuff
@@ -43,17 +43,15 @@ use \SplFileInfo;
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 abstract class BaseTemplateEngine extends BaseFrameworkSystem {
+       // Load traits
+       use IoHandlerTrait;
+
        // Exception codes for the template engine
        const EXCEPTION_TEMPLATE_TYPE_IS_UNEXPECTED   = 0x110;
        const EXCEPTION_TEMPLATE_CONTAINS_INVALID_VAR = 0x111;
        const EXCEPTION_INVALID_VIEW_HELPER           = 0x112;
        const EXCEPTION_VARIABLE_IS_MISSING           = 0x113;
 
-       /**
-        * The file I/O instance for the template loader
-        */
-       private $fileIoInstance = NULL;
-
        /**
         * The local path name where all templates and sub folders for special
         * templates are stored. We will internally determine the language plus
@@ -1621,25 +1619,6 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem {
                return $this->xmlCompacting;
        }
 
-       /**
-        * Private getter for file IO instance
-        *
-        * @return      $fileIoInstance         An instance to the file I/O sub-system
-        */
-       protected final function getFileIoInstance () {
-               return $this->fileIoInstance;
-       }
-
-       /**
-        * Setter for file I/O instance
-        *
-        * @param       $fileIoInstance         An instance to the file I/O sub-system
-        * @return      void
-        */
-       public final function setFileIoInstance (IoHandler $fileIoInstance) {
-               $this->fileIoInstance = $fileIoInstance;
-       }
-
        /**
         * Setter for stacker instance
         *
index e6c866fd7140315ddf7c80e48e1793f66fe6e487..314a75ad894d323dd6f449b550cfbb3b20a66d04 100644 (file)
@@ -54,10 +54,6 @@ abstract class FrameworkException extends ReflectionException {
                // Extract backtrace
                $this->saveBackTrace();
 
-               // Cast all data
-               $message = (string) $message;
-               $code    = (int)    $code;
-
                // In emergency exit?
                if (defined('EMERGENCY_EXIT_CALLED')) {
                        // Output message
index d37cbf25fc521a241bc89ecac532c036654728ce..8154bcf278651288d1f938f623a842e5e080c56c 100644 (file)
@@ -34,14 +34,14 @@ interface DatabaseFrontend extends FrameworkInterface {
         *
         * @return      $indexKey       Index key
         */
-       function getIndexKey();
+       function getIndexKey ();
 
        /**
         * Getter for last exception
         *
         * @return      $lastException  Last exception or NULL if none occured
         */
-       function getLastException();
+       function getLastException ();
 
        /**
         * Do a "select" query on the current table with the given search criteria and
@@ -51,7 +51,7 @@ interface DatabaseFrontend extends FrameworkInterface {
         * @param       $onlyKeys                       Only use these keys for a cache key
         * @return      $resultInstance         An instance of a database result class
         */
-       function doSelectByCriteria(Criteria $criteriaInstance, array $onlyKeys = []);
+       function doSelectByCriteria (Criteria $criteriaInstance, array $onlyKeys = []);
 
        /**
         * Count the numbers of rows we shall receive
@@ -60,20 +60,20 @@ interface DatabaseFrontend extends FrameworkInterface {
         * @param       $onlyKeys                       Only use these keys for a cache key
         * @return      $numRows                        Numbers of rows of database entries
         */
-       function doSelectCountByCriteria(Criteria $criteriaInstance, array $onlyKeys = []);
+       function doSelectCountByCriteria (Criteria $criteriaInstance, array $onlyKeys = []);
 
        /**
         * Getter for primary key used in wrapped table
         *
         * @return      $primaryKey             Primary key used in wrapped table
         */
-       function getPrimaryKeyValue();
+       function getPrimaryKeyValue ();
 
        /**
         * Counts total rows of this table
         *
         * @return      $count  Total rows of this table
         */
-       function countTotalRows();
+       function countTotalRows ();
 
 }
index 3f10caded4c10556c6950860b199135223ad1641..f4d66e9a0fd7b4db09263bcfd0b1225791026069 100644 (file)
@@ -47,7 +47,7 @@ interface DatabaseConnector extends FrameworkDatabase {
         * @param       $host   Hostname to use
         * @return      void
         */
-       function setConnectionData ($login, $pass, $dbase, $host='localhost');
+       function setConnectionData (string $login, string $pass, string $dbase, string $host = 'localhost');
 
        /**
         * Getter for connection data
@@ -78,7 +78,7 @@ interface DatabaseConnector extends FrameworkDatabase {
         * @param       $criteriaInstance       An instance of a Criteria class
         * @return      $result                         The result as an array
         */
-       function doSelectByTableCriteria ($tableName, Criteria $criteriaInstance);
+       function doSelectByTableCriteria (string $tableName, Criteria $criteriaInstance);
 
        /**
         * Getter for last exception
@@ -109,7 +109,7 @@ interface DatabaseConnector extends FrameworkDatabase {
         * @param       $tableName              Name of table we need the primary key column from
         * @return      $primaryKey             Primary key column of requested table
         */
-       function getPrimaryKeyOfTable ($tableName);
+       function getPrimaryKeyOfTable (string $tableName);
 
        /**
         * Removes non-public data from given array.
@@ -125,6 +125,6 @@ interface DatabaseConnector extends FrameworkDatabase {
         * @param       $tableName      Table name
         * @return      $count          Total rows of given table
         */
-       function countTotalRows($tableName);
+       function countTotalRows (string $tableName);
 
 }
index 60ffaf11776376ee3e9505363da96dd5414b643f..7e01bc05c79f6b165d822c7008860e27038ce999 100644 (file)
@@ -102,12 +102,12 @@ class DatabaseConnection extends BaseMiddleware implements DatabaseConnector, Re
         * @param       $host   Host to connect to (default: 127.0.0.1)
         * @return      void
         */
-       public final function setConnectionData ($login, $pass, $dbase, $host = '127.0.0.1') {
+       public final function setConnectionData (string $login, string $pass, string $dbase, string $host = '127.0.0.1') {
                // Transfer connection data
-               $this->connectData['login'] = (string) $login;
-               $this->connectData['pass']  = (string) $pass;
-               $this->connectData['dbase'] = (string) $dbase;
-               $this->connectData['host']  = (string) $host;
+               $this->connectData['login'] = $login;
+               $this->connectData['pass']  = $pass;
+               $this->connectData['dbase'] = $dbase;
+               $this->connectData['host']  = $host;
        }
 
        /**
@@ -145,7 +145,7 @@ class DatabaseConnection extends BaseMiddleware implements DatabaseConnector, Re
         * @param       $criteriaInstance       An instance of a Criteria class
         * @return      $result                         The result as an array
         */
-       public function doSelectByTableCriteria ($tableName, Criteria $criteriaInstance) {
+       public function doSelectByTableCriteria (string $tableName, Criteria $criteriaInstance) {
                // Connect to the database
                $this->dbLayer->connectToDatabase();
 
@@ -200,7 +200,7 @@ class DatabaseConnection extends BaseMiddleware implements DatabaseConnector, Re
         * @param       $tableName              Name of table we need the primary key column from
         * @return      $primaryKey             Primary key column of requested table
         */
-       public function getPrimaryKeyOfTable ($tableName) {
+       public function getPrimaryKeyOfTable (string $tableName) {
                // Connect to the database
                $this->dbLayer->connectToDatabase();
 
@@ -235,7 +235,7 @@ class DatabaseConnection extends BaseMiddleware implements DatabaseConnector, Re
         * @param       $tableName      Table name
         * @return      $count          Total row count
         */
-       public function countTotalRows ($tableName) {
+       public function countTotalRows (string $tableName) {
                // Connect to the database
                $this->dbLayer->connectToDatabase();
 
diff --git a/framework/main/traits/cache/class_CacheableTrait.php b/framework/main/traits/cache/class_CacheableTrait.php
new file mode 100644 (file)
index 0000000..e523f1b
--- /dev/null
@@ -0,0 +1,55 @@
+<?php
+// Own namespace
+namespace Org\Mxchange\CoreFramework\Traits\Cache;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Cache\Cacheable;
+
+/**
+ * A trait for cache
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+trait CacheableTrait {
+       /**
+        * Cache instance
+        */
+       private $cacheInstance = NULL;
+
+       /**
+        * Setter for table name
+        *
+        * @param       $cacheInstance  Name of table name to set
+        * @return      void
+        */
+       protected final function setCacheInstance (Cacheable $cacheInstance) {
+               $this->cacheInstance = $cacheInstance;
+       }
+
+       /**
+        * Getter for table name
+        *
+        * @return      $cacheInstance  Name of table name to set
+        */
+       protected final function getCacheInstance () {
+               return $this->cacheInstance;
+       }
+
+}
diff --git a/framework/main/traits/compressor/class_CompressorChannelTrait.php b/framework/main/traits/compressor/class_CompressorChannelTrait.php
new file mode 100644 (file)
index 0000000..42409cf
--- /dev/null
@@ -0,0 +1,55 @@
+<?php
+// Own namespace
+namespace Org\Mxchange\CoreFramework\Traits\Compressor\Channel;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Middleware\Compressor\CompressorChannel;
+
+/**
+ * A trait for compressor channels
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+trait CompressorChannelTrait {
+       /**
+        * A Compressor instance
+        */
+       private $compressorChannelInstance = NULL;
+
+       /**
+        * Setter for compressor channel
+        *
+        * @param       $compressorChannelInstance      An instance of a CompressorChannel class
+        * @return      void
+        */
+       protected final function setCompressorChannelInstance (CompressorChannel $compressorChannelInstance) {
+               $this->compressorChannelInstance = $compressorChannelInstance;
+       }
+
+       /**
+        * Getter for compressor channel
+        *
+        * @return      $compressorChannelInstance      An instance of a CompressorChannel class
+        */
+       protected final function getCompressorChannelInstance () {
+               return $this->compressorChannelInstance;
+       }
+
+}
diff --git a/framework/main/traits/handler/io/class_IoHandlerTrait.php b/framework/main/traits/handler/io/class_IoHandlerTrait.php
new file mode 100644 (file)
index 0000000..8aba0fb
--- /dev/null
@@ -0,0 +1,55 @@
+<?php
+// Own namespace
+namespace Org\Mxchange\CoreFramework\Traits\Handler\Io;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Handler\Stream\IoHandler;
+
+/**
+ * A trait for file I/O handler
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+trait IoHandlerTrait {
+       /**
+        * The file I/O instance for the template loader
+        */
+       private $fileIoInstance = NULL;
+
+       /**
+        * Private getter for file IO instance
+        *
+        * @return      $fileIoInstance         An instance to the file I/O sub-system
+        */
+       protected final function getFileIoInstance () {
+               return $this->fileIoInstance;
+       }
+
+       /**
+        * Setter for file I/O instance
+        *
+        * @param       $fileIoInstance         An instance to the file I/O sub-system
+        * @return      void
+        */
+       public final function setFileIoInstance (IoHandler $fileIoInstance) {
+               $this->fileIoInstance = $fileIoInstance;
+       }
+
+}