|
42 | 42 | /** |
43 | 43 | * The response returned from the service. |
44 | 44 | */ |
45 | | -class Response |
| 45 | +readonly class Response |
46 | 46 | { |
47 | | - /** |
48 | | - * Success or failure. |
49 | | - */ |
50 | | - private bool $success = false; |
51 | | - |
52 | | - /** |
53 | | - * Error code strings. |
54 | | - * |
55 | | - * @var array<string> |
56 | | - */ |
57 | | - private array $errorCodes = []; |
58 | | - |
59 | | - /** |
60 | | - * The hostname of the site where the reCAPTCHA was solved. |
61 | | - */ |
62 | | - private string $hostname; |
63 | | - |
64 | | - /** |
65 | | - * Timestamp of the challenge load (ISO format yyyy-MM-dd'T'HH:mm:ssZZ). |
66 | | - */ |
67 | | - private string $challengeTs; |
68 | | - |
69 | | - /** |
70 | | - * APK package name. |
71 | | - */ |
72 | | - private string $apkPackageName; |
73 | | - |
74 | | - /** |
75 | | - * Score assigned to the request. |
76 | | - */ |
77 | | - private ?float $score; |
78 | | - |
79 | | - /** |
80 | | - * Action as specified by the page. |
81 | | - */ |
82 | | - private string $action; |
83 | | - |
84 | 47 | /** |
85 | 48 | * Constructor. |
86 | 49 | * |
87 | | - * @param array<string> $errorCodes |
88 | | - */ |
89 | | - public function __construct(bool $success, array $errorCodes = [], string $hostname = '', string $challengeTs = '', string $apkPackageName = '', ?float $score = null, string $action = '') |
90 | | - { |
91 | | - $this->success = $success; |
92 | | - $this->hostname = $hostname; |
93 | | - $this->challengeTs = $challengeTs; |
94 | | - $this->apkPackageName = $apkPackageName; |
95 | | - $this->score = $score; |
96 | | - $this->action = $action; |
97 | | - $this->errorCodes = $errorCodes; |
98 | | - } |
| 50 | + * @param bool $success success or failure |
| 51 | + * @param array<string> $errorCodes error code strings |
| 52 | + * @param string $hostname the hostname of the site where the reCAPTCHA was solved |
| 53 | + * @param string $challengeTs timestamp of the challenge load (ISO format yyyy-MM-dd'T'HH:mm:ssZZ) |
| 54 | + * @param string $apkPackageName APK package name |
| 55 | + * @param ?float $score score assigned to the request |
| 56 | + * @param string $action action as specified by the page |
| 57 | + */ |
| 58 | + public function __construct( |
| 59 | + private bool $success, |
| 60 | + private array $errorCodes = [], |
| 61 | + private string $hostname = '', |
| 62 | + private string $challengeTs = '', |
| 63 | + private string $apkPackageName = '', |
| 64 | + private ?float $score = null, |
| 65 | + private string $action = '', |
| 66 | + ) {} |
99 | 67 |
|
100 | 68 | /** |
101 | 69 | * Build the response from the expected JSON returned by the service. |
|
0 commit comments