PicOperationsTransformation.php
1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
namespace Qcloud\Cos\ImageParamTemplate;
/**
* Class PicOperationsTransformation 图片处理参数 Pic-Operations
* @package Qcloud\Cos\ImageParamTemplate
*/
class PicOperationsTransformation {
private $isPicInfo;
private $rules;
public function __construct() {
$this->isPicInfo = 0;
$this->rules = array();
}
public function setIsPicInfo($value) {
$this->isPicInfo = $value;
}
public function addRule(ImageTemplate $template, $fileid = "", $bucket = "") {
$rule = $template->queryString();
if($rule){
$item = array();
$item['rule'] = $rule;
if($fileid){
$item['fileid'] = $fileid;
}
if($bucket) {
$item['bucket'] = $bucket;
}
$this->rules[] = $item;
}
}
public function getIsPicInfo() {
return $this->isPicInfo;
}
public function getRules() {
return $this->rules;
}
public function queryString() {
$res = "";
$picOperations = array();
if($this->isPicInfo){
$picOperations['is_pic_info'] = $this->isPicInfo;
}
if($this->rules){
$picOperations['rules'] = $this->rules;
}
if($picOperations){
$res = json_encode($picOperations);
}
return $res;
}
public function resetRule() {
$this->isPicInfo = 0;
$this->rules = array();
}
}