TCaptchaV3::verify()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 10
c 1
b 0
f 1
nc 1
nop 4
dl 0
loc 13
ccs 0
cts 12
cp 0
crap 2
rs 9.9332
1
<?php
2
3
namespace Freyo\Flysystem\QcloudCOSv5\Plugins;
4
5
use Freyo\Flysystem\QcloudCOSv5\Plugins\Traits\TencentCloudAuthV3;
6
use League\Flysystem\Plugin\AbstractPlugin;
7
8
class TCaptchaV3 extends AbstractPlugin
9
{
10
    use TencentCloudAuthV3;
11
12
    const RESPONSE_SUCCESS = 1;
13
14
    protected $aid;
15
    protected $appSecretKey;
16
17
    /**
18
     * Get the method name.
19
     *
20
     * @return string
21
     */
22
    public function getMethod()
23
    {
24
        return 'TCaptchaV3';
25
    }
26
27
    /**
28
     * @param $aid
29
     * @param $appSecretKey
30
     *
31
     * @return $this
32
     */
33
    public function handle($aid, $appSecretKey)
34
    {
35
        $this->aid = $aid;
36
        $this->appSecretKey = $appSecretKey;
37
38
        return $this;
39
    }
40
41
    /**
42
     * @param $ticket
43
     * @param $randStr
44
     * @param $userIP
45
     * @param array $options
46
     *
47
     * @return bool|array
48
     */
49
    public function verify($ticket, $randStr, $userIP, array $options = [])
50
    {
51
        $params = array_merge([
52
            'CaptchaType'  => 9,
53
            'Ticket'       => $ticket,
54
            'UserIp'       => $userIP,
55
            'Randstr'      => $randStr,
56
            'CaptchaAppId' => $this->aid,
57
            'AppSecretKey' => $this->appSecretKey,
58
        ], $options);
59
60
        return $this->request(
61
            $params, 'DescribeCaptchaResult', 'captcha', '2019-07-22'
62
        );
63
    }
64
}
65