1 | <?php |
||
2 | |||
3 | namespace ByTIC\GoogleRecaptcha\Manager\Traits; |
||
4 | |||
5 | use ReCaptcha\ReCaptcha; |
||
6 | |||
7 | /** |
||
8 | * Trait HasClientTrait |
||
9 | * @package ByTIC\GoogleRecaptcha\Manager\Traits |
||
10 | */ |
||
11 | trait HasClientTrait |
||
12 | { |
||
13 | /** |
||
14 | * @var null|ReCaptcha |
||
15 | */ |
||
16 | protected $client = null; |
||
17 | |||
18 | /** |
||
19 | * @return ReCaptcha|null |
||
20 | */ |
||
21 | public function getClient(): ReCaptcha |
||
22 | { |
||
23 | if ($this->client === null) { |
||
24 | $this->initClient(); |
||
25 | } |
||
26 | return $this->client; |
||
27 | } |
||
28 | |||
29 | /** |
||
30 | * @param ReCaptcha|null $client |
||
31 | */ |
||
32 | public function setClient(?ReCaptcha $client): void |
||
33 | { |
||
34 | $this->client = $client; |
||
35 | } |
||
36 | |||
37 | protected function initClient() |
||
38 | { |
||
39 | $client = new \ReCaptcha\ReCaptcha($this->getSecretKey()); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
40 | $this->setClient($client); |
||
41 | } |
||
42 | } |