Passed
Push — master ( 93ae1f...c8123d )
by TQ
04:05
created

SyncVideo   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
dl 0
loc 28
ccs 16
cts 16
cp 1
rs 10
c 1
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A process() 0 17 1
1
<?php
2
/**
3
 * 同步视频处理
4
 */
5
6
namespace Upyun\Api;
7
8
use GuzzleHttp\Client;
9
use Upyun\Config;
10
use Upyun\Signature;
11
12
13
class SyncVideo {
14
    /**
15
     * @var Config
16
     */
17
    protected $config;
18
19 2
    public function __construct(Config $config)
20
    {
21 2
        $this->config = $config;
22
    }
23
24 2
    public function process($params, $path) {
25 2
        $client = new Client([
26 2
            'timeout' => $this->config->timeout,
27 2
        ]);
28
29 2
        $path = '/' . $this->config->serviceName . $path;
30 2
        $method = 'POST';
31 2
        $signedHeaders = Signature::getHeaderSign($this->config, $method, $path);
32
33 2
        $url = $this->config->getSyncVideoEndPoint() . $path;
34 2
        $response = $client->request($method, $url, [
35 2
            'headers' => $signedHeaders,
36 2
            'json' => $params
37 2
        ]);
38
39 2
        $body = $response->getBody()->getContents();
40 2
        return json_decode($body, true);
41
    }
42
}