]> git.mxchange.org Git - core.git/blobdiff - framework/main/classes/database/backend/lfdb_legacy/class_CachedLocalFileDatabase.php
Refacuring:
[core.git] / framework / main / classes / database / backend / lfdb_legacy / class_CachedLocalFileDatabase.php
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