Passed
Push — master ( e39da6...9f5525 )
by sabaku
04:31
created

SyncVideo   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 30
ccs 16
cts 16
cp 1
rs 10
wmc 2
lcom 1
cbo 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A process() 0 18 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 2
    }
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
            'json' => $params
37 2
        ]);
38
39 2
        $body = $response->getBody()->getContents();
40 2
        return json_decode($body, true);
41
    }
42
}