]> git.mxchange.org Git - core.git/blob - framework/main/classes/helper/captcha/class_BaseCaptcha.php
Continued:
[core.git] / framework / main / classes / helper / captcha / class_BaseCaptcha.php
1 <?php
2 // Own namespace
3 namespace Org\Mxchange\CoreFramework\Helper\Captcha;
4
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;
11
12 /**
13  * A general captcha
14  *
15  * @author              Roland Haeder <webmaster@shipsimu.org>
16  * @version             0.0.0
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
20  *
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.
25  *
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.
30  *
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/>.
33  */
34 abstract class BaseCaptcha extends BaseHelper {
35         /**
36          * Instance of a RNG
37          */
38         private $rngInstance = NULL;
39
40         /**
41          * A helper instance for the form
42          */
43         private $helperInstance = NULL;
44
45         /**
46          * Protected constructor
47          *
48          * @param       $className      Name of the class
49          * @return      void
50          */
51         protected function __construct (string $className) {
52                 // Call parent constructor
53                 parent::__construct($className);
54         }
55
56         /**
57          * Setter for RNG instance
58          *
59          * @param       $rngInstance    An instance of a random number generator (RNG)
60          * @return      void
61          */
62         protected final function setRngInstance (RandomNumberGenerator $rngInstance) {
63                 $this->rngInstance = $rngInstance;
64         }
65
66         /**
67          * Getter for RNG instance
68          *
69          * @return      $rngInstance    An instance of a random number generator (RNG)
70          */
71         public final function getRngInstance () {
72                 return $this->rngInstance;
73         }
74
75         /**
76          * Setter for helper instance
77          *
78          * @param       $helperInstance         An instance of a helper class
79          * @return      void
80          */
81         protected final function setHelperInstance (Helper $helperInstance) {
82                 $this->helperInstance = $helperInstance;
83         }
84
85         /**
86          * Getter for helper instance
87          *
88          * @return      $helperInstance         An instance of a helper class
89          */
90         public final function getHelperInstance () {
91                 return $this->helperInstance;
92         }
93
94         /**
95          * Initializes the random number generator (RNG)
96          *
97          * @param       $extraInstance  An extra instance, just for better hash data
98          * @return      void
99          */
100         protected final function initializeRandomNumberGenerator (FrameworkInterface $extraInstance = NULL) {
101                 // Get an RNG from factory
102                 $this->setRngInstance(ObjectFactory::createObjectByConfiguredName('rng_class', array($extraInstance)));
103         }
104
105 }