3 namespace Org\Mxchange\CoreFramework\Helper\Captcha;
5 // Import framework stuff
6 use Org\Mxchange\CoreFramework\Crypto\RandomNumber\RandomNumberGenerator;
7 use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
8 use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
9 use Org\Mxchange\CoreFramework\Helper\BaseHelper;
10 use Org\Mxchange\CoreFramework\Helper\Helper;
11 use Org\Mxchange\CoreFramework\Traits\Helper\HelperTrait;
16 * @author Roland Haeder <webmaster@shipsimu.org>
18 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
19 * @license GNU GPL 3.0 or any newer version
20 * @link http://www.shipsimu.org
22 * This program is free software: you can redistribute it and/or modify
23 * it under the terms of the GNU General Public License as published by
24 * the Free Software Foundation, either version 3 of the License, or
25 * (at your option) any later version.
27 * This program is distributed in the hope that it will be useful,
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 * GNU General Public License for more details.
32 * You should have received a copy of the GNU General Public License
33 * along with this program. If not, see <http://www.gnu.org/licenses/>.
35 abstract class BaseCaptcha extends BaseHelper implements Helper {
42 private $rngInstance = NULL;
45 * Protected constructor
47 * @param $className Name of the class
50 protected function __construct (string $className) {
51 // Call parent constructor
52 parent::__construct($className);
56 * Setter for RNG instance
58 * @param $rngInstance An instance of a random number generator (RNG)
61 protected final function setRngInstance (RandomNumberGenerator $rngInstance) {
62 $this->rngInstance = $rngInstance;
66 * Getter for RNG instance
68 * @return $rngInstance An instance of a random number generator (RNG)
70 public final function getRngInstance () {
71 return $this->rngInstance;
75 * Initializes the random number generator (RNG)
77 * @param $extraInstance An extra instance, just for better hash data
80 protected final function initializeRandomNumberGenerator (FrameworkInterface $extraInstance = NULL) {
81 // Get an RNG from factory
82 $this->setRngInstance(ObjectFactory::createObjectByConfiguredName('rng_class', array($extraInstance)));