]> git.mxchange.org Git - core.git/commitdiff
Refacturing:
authorRoland Häder <roland@mxchange.org>
Wed, 2 Dec 2020 18:42:58 +0000 (19:42 +0100)
committerRoland Häder <roland@mxchange.org>
Wed, 2 Dec 2020 18:42:58 +0000 (19:42 +0100)
- introduced RegisterTrait instead of $registryInstance

Signed-off-by: Roland Häder <roland@mxchange.org>
framework/main/classes/iterator/registry/class_RegistryIterator.php
framework/main/traits/registry/class_RegisterTrait.php [new file with mode: 0644]

index 9c9d0b4a44053849aeb6c5a4e7a6c261f193545e..8b331182704561a6baea1e75c755fe4da997b059 100644 (file)
@@ -6,9 +6,9 @@ namespace Org\Mxchange\CoreFramework\Iterator\Registry;
 use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
 use Org\Mxchange\CoreFramework\Generic\NullPointerException;
 use Org\Mxchange\CoreFramework\Iterator\BaseIterator;
-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;
@@ -37,6 +37,9 @@ use \LogicException;
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 class RegistryIterator extends BaseIterator implements IteratableRegistry {
+       // Load traits
+       use RegisterTrait;
+
        /**
         * All found registry keys
         */
@@ -53,11 +56,6 @@ class RegistryIterator extends BaseIterator implements IteratableRegistry {
         */
        private $key = NULL;
 
-       /**
-        * Registry instance (implementing Register)
-        */
-       private $registryInstance = NULL;
-
        /**
         * Protected constructor
         *
@@ -93,25 +91,6 @@ class RegistryIterator extends BaseIterator implements IteratableRegistry {
                return $iteratorInstance;
        }
 
-       /**
-        * Setter for registry instance
-        *
-        * @param       $registryInstance               An instance of a Register class
-        * @return      void
-        */
-       protected final function setRegistryInstance (Register $registryInstance) {
-               $this->registryInstance = $registryInstance;
-       }
-
-       /**
-        * Getter for registry instance
-        *
-        * @return      $registryInstance       The debug registry instance
-        */
-       protected final function getRegistryInstance () {
-               return $this->registryInstance;
-       }
-
        /**
         * Setter for only-registries array
         *
diff --git a/framework/main/traits/registry/class_RegisterTrait.php b/framework/main/traits/registry/class_RegisterTrait.php
new file mode 100644 (file)
index 0000000..b8d5a58
--- /dev/null
@@ -0,0 +1,55 @@
+<?php
+// Own namespace
+namespace Org\Mxchange\CoreFramework\Traits\Registry;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Registry\Register;
+
+/**
+ * A trait for registries
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.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.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/>.
+ */
+trait RegisterTrait {
+       /**
+        * Registry instance (implementing Register)
+        */
+       private $registryInstance = NULL;
+
+       /**
+        * Setter for registry instance
+        *
+        * @param       $registryInstance               An instance of a Register class
+        * @return      void
+        */
+       protected final function setRegistryInstance (Register $registryInstance) {
+               $this->registryInstance = $registryInstance;
+       }
+
+       /**
+        * Getter for registry instance
+        *
+        * @return      $registryInstance       The debug registry instance
+        */
+       protected final function getRegistryInstance () {
+               return $this->registryInstance;
+       }
+
+}