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

SyncVideo::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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