*/
private $rndStrLen = 0;
+ /**
+ * Self instance
+ */
+ private static $selfInstance = NULL;
+
/**
* Protected constructor
*
* @return $rngInstance An instance of this random number generator
*/
public static final function createRandomNumberGenerator (FrameworkInterface $extraInstance = NULL) {
- // Get a new instance
- $rngInstance = new RandomNumberGenerator();
+ // Is self instance set?
+ if (is_null(self::$selfInstance)) {
+ // Get a new instance
+ $rngInstance = new RandomNumberGenerator();
- // Initialize the RNG now
- $rngInstance->initRng($extraInstance);
+ // Initialize the RNG now
+ $rngInstance->initRng($extraInstance);
+
+ // Set it "self"
+ self::$selfInstance = $rngInstance;
+ } else {
+ // Use from self instance
+ $rngInstance = self::$selfInstance;
+ }
// Return the instance
return $rngInstance;