1 | <?php |
||
7 | class ReCaptcha2 extends AbstractAdapter |
||
8 | { |
||
9 | /** |
||
10 | * @var ServiceInterface |
||
11 | */ |
||
12 | protected $service; |
||
13 | |||
14 | /**#@+ |
||
15 | * Error codes |
||
16 | */ |
||
17 | const ERROR_CAPTCHA_GENERAL = 'error-captcha-general'; |
||
18 | const MISSING_INPUT_RESPONSE = 'missing-input-response'; |
||
19 | const INVALID_INPUT_RESPONSE = 'invalid-input-response'; |
||
20 | const MISSING_INPUT_SECRET = 'missing-input-secret'; |
||
21 | const INVALID_INPUT_SECRET = 'invalid-input-secret'; |
||
22 | /**#@-*/ |
||
23 | |||
24 | /** |
||
25 | * Error messages |
||
26 | * @var array |
||
27 | */ |
||
28 | protected $messageTemplates = [ |
||
29 | self::ERROR_CAPTCHA_GENERAL => 'Failed to validate captcha', |
||
30 | self::MISSING_INPUT_RESPONSE => 'Missing captcha fields', |
||
31 | self::INVALID_INPUT_RESPONSE => 'Captcha value is wrong: %value%', |
||
32 | self::MISSING_INPUT_SECRET => 'Missing captcha secret', |
||
33 | self::INVALID_INPUT_SECRET => 'Invalid captcha secret', |
||
34 | ]; |
||
35 | |||
36 | /** |
||
37 | * @param array|\Traversable $options |
||
38 | * @throws Exception\DomainException |
||
39 | * @return ReCaptcha2 |
||
40 | */ |
||
41 | public function setOptions($options = []) |
||
52 | |||
53 | /** |
||
54 | * @return ServiceInterface |
||
55 | */ |
||
56 | public function getService() |
||
63 | |||
64 | /** |
||
65 | * @param array|\Traversable|ServiceInterface $service |
||
66 | * @return ReCaptcha2 |
||
67 | */ |
||
68 | public function setService($service) |
||
97 | |||
98 | /** |
||
99 | * @see ServiceInterface::getSiteKey() |
||
100 | */ |
||
101 | public function getSiteKey() |
||
105 | |||
106 | /** |
||
107 | * @see ServiceInterface::setSiteKey() |
||
108 | */ |
||
109 | public function setSiteKey($siteKey) |
||
114 | |||
115 | /** |
||
116 | * @see ServiceInterface::getSecretKey() |
||
117 | */ |
||
118 | public function getSecretKey() |
||
122 | |||
123 | /** |
||
124 | * @see ServiceInterface::setSecretKey() |
||
125 | */ |
||
126 | public function setSecretKey($secretKey) |
||
131 | |||
132 | /** |
||
133 | * @see AbstractAdapter::generate() |
||
134 | * @return string |
||
135 | */ |
||
136 | public function generate() |
||
140 | |||
141 | /** |
||
142 | * @see \Zend\Validator\ValidatorInterface::isValid() |
||
143 | * @param mixed $value |
||
144 | * @param mixed $context |
||
145 | * @return boolean |
||
146 | */ |
||
147 | public function isValid($value, $context = null) |
||
186 | |||
187 | /** |
||
188 | * @return string |
||
189 | */ |
||
190 | public function getHelperName() |
||
194 | } |
||
195 |