1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* This file is part of the ReCaptcha Library. |
4
|
|
|
* |
5
|
|
|
* (c) Ilya Pokamestov <[email protected]> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace DS\Library\ReCaptcha; |
12
|
|
|
|
13
|
|
|
use Psr\Http\Message\RequestInterface; |
14
|
|
|
use Psr\Http\Message\ResponseInterface; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* ReCaptcha library, validation exception. |
18
|
|
|
* |
19
|
|
|
* @author Ilya Pokamestov <[email protected]> |
20
|
|
|
*/ |
21
|
|
|
class ValidationException extends \Exception |
22
|
|
|
{ |
23
|
|
|
/** @var array */ |
24
|
|
|
protected $errors = array(); |
25
|
|
|
/** @var RequestInterface */ |
26
|
|
|
protected $request; |
27
|
|
|
/** @var ResponseInterface */ |
28
|
|
|
protected $response; |
29
|
|
|
|
30
|
2 |
|
public function __construct( |
31
|
|
|
array $errors, |
32
|
|
|
ResponseInterface $response = null, |
33
|
|
|
RequestInterface $request = null, |
34
|
|
|
$message = '', |
35
|
|
|
$code = 0, |
36
|
|
|
\Exception $previous = null |
37
|
|
|
) { |
38
|
2 |
|
$this->errors = $errors; |
39
|
2 |
|
$this->request = $request; |
40
|
2 |
|
$this->response = $response; |
41
|
|
|
|
42
|
2 |
|
if ('' === $message) { |
43
|
2 |
|
$message = sprintf('Verification failed with errors: %s', implode(';', $errors)); |
44
|
2 |
|
} |
45
|
|
|
|
46
|
2 |
|
parent::__construct($message, $code, $previous); |
47
|
2 |
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @return RequestInterface |
51
|
|
|
*/ |
52
|
1 |
|
public function getRequest() |
53
|
|
|
{ |
54
|
1 |
|
return $this->request; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @return ResponseInterface |
59
|
|
|
*/ |
60
|
1 |
|
public function getResponse() |
61
|
|
|
{ |
62
|
1 |
|
return $this->response; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @return array |
67
|
|
|
*/ |
68
|
1 |
|
public function getErrors() |
69
|
|
|
{ |
70
|
1 |
|
return $this->errors; |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|