TCaptcha   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 21
c 1
b 0
f 1
dl 0
loc 56
ccs 0
cts 25
cp 0
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getMethod() 0 3 1
A verify() 0 16 1
A handle() 0 6 1
1
<?php
2
3
namespace Freyo\Flysystem\QcloudCOSv5\Plugins;
4
5
use League\Flysystem\Plugin\AbstractPlugin;
6
7
class TCaptcha extends AbstractPlugin
8
{
9
    const TICKET_VERIFY = 'https://ssl.captcha.qq.com/ticket/verify';
10
11
    const RESPONSE_SUCCESS = 1;
12
13
    protected $aid;
14
    protected $appSecretKey;
15
16
    /**
17
     * Get the method name.
18
     *
19
     * @return string
20
     */
21
    public function getMethod()
22
    {
23
        return 'tcaptcha';
24
    }
25
26
    /**
27
     * @param $aid
28
     * @param $appSecretKey
29
     *
30
     * @return $this
31
     */
32
    public function handle($aid, $appSecretKey)
33
    {
34
        $this->aid = $aid;
35
        $this->appSecretKey = $appSecretKey;
36
37
        return $this;
38
    }
39
40
    /**
41
     * @param $ticket
42
     * @param $randStr
43
     * @param $userIP
44
     *
45
     * @return mixed
46
     */
47
    public function verify($ticket, $randStr, $userIP)
48
    {
49
        $contents = $this->filesystem
50
            ->getAdapter()
51
            ->getHttpClient()
52
            ->get(self::TICKET_VERIFY, ['query' => [
53
                'aid'          => $this->aid,
54
                'AppSecretKey' => $this->appSecretKey,
55
                'Ticket'       => $ticket,
56
                'Randstr'      => $randStr,
57
                'UserIP'       => $userIP,
58
            ]])
59
            ->getBody()
60
            ->getContents();
61
62
        return \GuzzleHttp\json_decode($contents);
63
    }
64
}
65