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

SyncVideo::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
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
}