<?php
// Own namespace
-namespace CoreFramework\Factory;
+namespace Org\Mxchange\CoreFramework\Factory;
// Import framework stuff
-use CoreFramework\Object\BaseFrameworkSystem;
+use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
/**
* A general (base) factory
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
+ * @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
*
* 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 BaseFactory extends BaseFrameworkSystem {
+abstract class BaseFactory extends BaseFrameworkSystem {
/**
* Total objects generated
*/
/**
* Counter of all objects
*/
- private static $objectCounters = array();
+ private static $objectCounters = [];
/**
* Protected constructor
* @param $className Name of the real class (not BaseFactory)
* @return void
*/
- protected function __construct ($className) {
+ protected function __construct (string $className) {
// Call parent constructor
parent::__construct($className);
}
/**
* Count given object
*
- * @param $className Name of the class we shall count
+ * @param $fullClassName Name of the class we shall count
*/
- protected static final function countObject ($className) {
+ protected static final function countObject (string $fullClassName) {
// Count it up in total sum
self::$total++;
// Do we have an entry?
- if (!isset(self::$objectCounters[$className])) {
+ if (!self::isClassCounted($fullClassName)) {
// No, then generate one
- self::$objectCounters[$className] = 0;
- } // END - if
+ self::$objectCounters[$fullClassName] = 0;
+ }
// Count it up again
- //* NOISY-DEBUG: */ print __METHOD__.': className=' .$className . PHP_EOL;
- self::$objectCounters[$className]++;
+ //* NOISY-DEBUG: */ print __METHOD__.': className=' .$fullClassName . PHP_EOL;
+ self::$objectCounters[$fullClassName]++;
}
/**
return self::$objectCounters;
}
+ /**
+ * Checks whether given full class name is already counted
+ *
+ * @param $fullClassName Full name of class
+ * @return $isCounted Whether given class name is counted
+ */
+ protected static final function isClassCounted (string $fullClassName) {
+ // Return isset() result
+ return isset(self::$objectCounters[$fullClassName]);
+ }
+
}