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\ObjectFactory;
8 use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
9 use Org\Mxchange\CoreFramework\Helper\BaseHelper;
10 use Org\Mxchange\CoreFramework\Helper\Helper;
15 * @author Roland Haeder <webmaster@shipsimu.org>
17 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
18 * @license GNU GPL 3.0 or any newer version
19 * @link http://www.shipsimu.org
21 * This program is free software: you can redistribute it and/or modify
22 * it under the terms of the GNU General Public License as published by
23 * the Free Software Foundation, either version 3 of the License, or
24 * (at your option) any later version.
26 * This program is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 * GNU General Public License for more details.
31 * You should have received a copy of the GNU General Public License
32 * along with this program. If not, see <http://www.gnu.org/licenses/>.
34 abstract class BaseCaptcha extends BaseHelper {
38 private $rngInstance = NULL;
41 * A helper instance for the form
43 private $helperInstance = NULL;
46 * Protected constructor
48 * @param $className Name of the class
51 protected function __construct (string $className) {
52 // Call parent constructor
53 parent::__construct($className);
57 * Setter for RNG instance
59 * @param $rngInstance An instance of a random number generator (RNG)
62 protected final function setRngInstance (RandomNumberGenerator $rngInstance) {
63 $this->rngInstance = $rngInstance;
67 * Getter for RNG instance
69 * @return $rngInstance An instance of a random number generator (RNG)
71 public final function getRngInstance () {
72 return $this->rngInstance;
76 * Setter for helper instance
78 * @param $helperInstance An instance of a helper class
81 protected final function setHelperInstance (Helper $helperInstance) {
82 $this->helperInstance = $helperInstance;
86 * Getter for helper instance
88 * @return $helperInstance An instance of a helper class
90 public final function getHelperInstance () {
91 return $this->helperInstance;
95 * Initializes the random number generator (RNG)
97 * @param $extraInstance An extra instance, just for better hash data
100 protected final function initializeRandomNumberGenerator (FrameworkInterface $extraInstance = NULL) {
101 // Get an RNG from factory
102 $this->setRngInstance(ObjectFactory::createObjectByConfiguredName('rng_class', array($extraInstance)));