PicOperationsTransformation.php 1.5 KB

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