TCaptchaV3   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 19
c 1
b 0
f 1
dl 0
loc 54
ccs 0
cts 22
cp 0
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A verify() 0 13 1
A getMethod() 0 3 1
A handle() 0 6 1
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