$applicationInstance = ApplicationHelper::getSelfInstance();
// Get a RNG instance (Random Number Generator)
- $rngInstance = ObjectFactory::createObjectByConfiguredName('rng_class');
+ $rngInstance = ObjectFactory::createObjectByConfiguredName('rng_class', [$this]);
// Generate a pseudo-random string
$randomString = $rngInstance->randomString(255);
$this->getTemplateInstance()->assignApplicationData();
// Get a mailer class
- $mailerInstance = ObjectFactory::createObjectByConfiguredName('mailer_class', array($this->getTemplateInstance(), 'resend_link'));
+ $mailerInstance = ObjectFactory::createObjectByConfiguredName('mailer_class', [$this->getTemplateInstance(), 'resend_link']);
// Set this mailer in our template engine
$this->getTemplateInstance()->setMailerInstance($mailerInstance);
*/
protected function initHasher (): void {
// Initialize the random number generator which is required by some crypto methods
- $this->setRngInstance(ObjectFactory::createObjectByConfiguredName('rng_class'));
+ $this->setRngInstance(ObjectFactory::createObjectByConfiguredName('rng_class', [$this]));
// Generate a salt for the hasher
$this->generateSalt();
*/
protected final function initializeRandomNumberGenerator (FrameworkInterface $extraInstance = NULL): void {
// Get an RNG from factory
- $this->setRngInstance(ObjectFactory::createObjectByConfiguredName('rng_class', array($extraInstance)));
+ $this->setRngInstance(ObjectFactory::createObjectByConfiguredName('rng_class', [$extraInstance]));
}
}
* @return void
* @todo Add site key for stronger salt!
*/
- protected function initRng ($extraInstance) {
+ protected function initRng (FrameworkInterface $extraInstance = NULL): void {
// Get the prime number from config
$this->prime = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('math_prime');
* @param $length Length of the string, default: 128
* @return $randomString The pseudo-random string
*/
- public function randomString ($length = -1) {
+ public function randomString (int $length = 0): string {
// Is the number <1, then fix it to default length
if ($length < 1) {
$length = $this->rndStrLen;
* @return $num Pseudo-random number
* @todo I had a better random number generator here but now it is somewhere lost :(
*/
- public function randomNumber ($min, $max) {
+ public function randomNumber (int $min, int $max): int {
return mt_rand($min, $max);
}
*
* @return $extraSalt
*/
- public final function getExtraSalt () {
+ public final function getExtraSalt (): string {
return $this->extraSalt;
}
*
* @return $fixedSalt
*/
- public final function getFixedSalt () {
+ public final function getFixedSalt (): string {
return $this->fixedSalt;
}
*
* @return $key The generated key for encryption
*/
- public function generateKey () {
+ public function generateKey (): string {
// Default is extra salt
$key = md5($this->getExtraSalt());