Complex classes like BucketManager often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use BucketManager, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 15 | final class BucketManager |
||
| 16 | { |
||
| 17 | private $auth; |
||
| 18 | private $config; |
||
| 19 | |||
| 20 | 42 | public function __construct(Auth $auth, Config $config = null) |
|
| 29 | |||
| 30 | /** |
||
| 31 | * 获取指定账号下所有的空间名。 |
||
| 32 | * |
||
| 33 | * @return string[] 包含所有空间名 |
||
| 34 | */ |
||
| 35 | 3 | public function buckets($shared = true) |
|
| 43 | |||
| 44 | /** |
||
| 45 | * 列举空间,返回bucket列表 |
||
| 46 | * region 指定区域,global 指定全局空间。 |
||
| 47 | * 在指定了 region 参数时, |
||
| 48 | * 如果指定 global 为 true,那么忽略 region 参数指定的区域,返回所有区域的全局空间。 |
||
| 49 | * 如果没有指定 global 为 true,那么返回指定区域中非全局空间。 |
||
| 50 | * 在没有指定 region 参数时(包括指定为空""), |
||
| 51 | * 如果指定 global 为 true,那么返回所有区域的全局空间。 |
||
| 52 | * 如果没有指定 global 为 true,那么返回指定区域中所有的空间,包括全局空间。 |
||
| 53 | * 在指定了line为 true 时,只返回 Line 空间;否则,只返回非 Line 空间。 |
||
| 54 | * share 参数用于指定共享空间。 |
||
| 55 | */ |
||
| 56 | |||
| 57 | public function listbuckets( |
||
| 66 | |||
| 67 | /** |
||
| 68 | * 创建空间 |
||
| 69 | * |
||
| 70 | * @param $name 创建的空间名 |
||
| 71 | * BucketName不满足以上要求返回400 (the specified bucket is not valid) |
||
| 72 | * 如果BucketName已经被使用,返回614(bucket exists) |
||
| 73 | * @param $region 创建的区域,默认华东 |
||
| 74 | * @return mixed 成功返回NULL,失败返回对象Qiniu\Http\Error |
||
| 75 | */ |
||
| 76 | |||
| 77 | public function createBucket($name, $region = 'z0') |
||
| 82 | |||
| 83 | /** |
||
| 84 | * 删除空间 |
||
| 85 | * |
||
| 86 | * @param $name 删除的空间名 |
||
| 87 | * |
||
| 88 | * @return mixed 成功返回NULL,失败返回对象Qiniu\Http\Error |
||
| 89 | */ |
||
| 90 | public function deleteBucket($name) |
||
| 95 | |||
| 96 | /** |
||
| 97 | * 获取指定空间绑定的所有的域名 |
||
| 98 | * |
||
| 99 | * @return string[] 包含所有空间域名 |
||
| 100 | */ |
||
| 101 | public function domains($bucket) |
||
| 105 | |||
| 106 | /** |
||
| 107 | * 获取指定空间的相关信息 |
||
| 108 | * |
||
| 109 | * @return string[] 包含空间信息 |
||
| 110 | */ |
||
| 111 | public function bucketInfo($bucket) |
||
| 117 | |||
| 118 | /** |
||
| 119 | * 获取指定zone的空间信息列表 |
||
| 120 | * 在Region 未指定且Global 不为 true 时(包含未指定的情况,下同),返回用户的所有空间。 |
||
| 121 | * 在指定了 region 参数且 global 不为 true 时,只列举非全局空间。 |
||
| 122 | * shared 不指定shared参数或指定shared为rw或false时,返回包含具有读写权限空间, |
||
| 123 | * 指定shared为rd或true时,返回包含具有读权限空间。 |
||
| 124 | * fs:如果为 true,会返回每个空间当前的文件数和存储量(实时数据)。 |
||
| 125 | * @return string[] 包含空间信息 |
||
| 126 | */ |
||
| 127 | public function bucketInfos($region = null, $shared = 'false', $fs = 'false') |
||
| 133 | |||
| 134 | /** |
||
| 135 | * 获取空间绑定的域名列表 |
||
| 136 | * @return string[] 包含空间绑定的所有域名 |
||
| 137 | */ |
||
| 138 | |||
| 139 | /** |
||
| 140 | * 列取空间的文件列表 |
||
| 141 | * |
||
| 142 | * @param $bucket 空间名 |
||
| 143 | * @param $prefix 列举前缀 |
||
| 144 | * @param $marker 列举标识符 |
||
| 145 | * @param $limit 单次列举个数限制 |
||
| 146 | * @param $delimiter 指定目录分隔符 |
||
| 147 | * |
||
| 148 | * @return array 包含文件信息的数组,类似:[ |
||
| 149 | * { |
||
| 150 | * "hash" => "<Hash string>", |
||
| 151 | * "key" => "<Key string>", |
||
| 152 | * "fsize" => "<file size>", |
||
| 153 | * "putTime" => "<file modify time>" |
||
| 154 | * }, |
||
| 155 | * ... |
||
| 156 | * ] |
||
| 157 | 3 | * @link http://developer.qiniu.com/docs/v6/api/reference/rs/list.html |
|
| 158 | */ |
||
| 159 | public function listFiles( |
||
| 174 | |||
| 175 | /** |
||
| 176 | * 列取空间的文件列表 |
||
| 177 | * |
||
| 178 | * @param $bucket 空间名 |
||
| 179 | * @param $prefix 列举前缀 |
||
| 180 | * @param $marker 列举标识符 |
||
| 181 | * @param $limit 单次列举个数限制 |
||
| 182 | * @param $delimiter 指定目录分隔符 |
||
| 183 | * @param $skipconfirm 是否跳过已删除条目的确认机制 |
||
| 184 | * |
||
| 185 | * @return array 包含文件信息的数组,类似:[ |
||
| 186 | * { |
||
| 187 | * "hash" => "<Hash string>", |
||
| 188 | * "key" => "<Key string>", |
||
| 189 | * "fsize" => "<file size>", |
||
| 190 | * "putTime" => "<file modify time>" |
||
| 191 | * }, |
||
| 192 | * ... |
||
| 193 | * ] |
||
| 194 | * @link http://developer.qiniu.com/docs/v6/api/reference/rs/list.html |
||
| 195 | */ |
||
| 196 | public function listFilesv2( |
||
| 221 | |||
| 222 | /** |
||
| 223 | * 设置Referer防盗链 |
||
| 224 | * |
||
| 225 | * @param $bucket 空间名 |
||
| 226 | * @param $mode 0: 表示关闭Referer(使用此选项将会忽略以下参数并将恢复默认值); |
||
| 227 | * 1: 表示设置Referer白名单; 2:表示设置Referer黑名单 |
||
| 228 | * @param $norefer 0: 表示不允许空 Refer 访问; 1: 表示允许空 Refer 访问 |
||
| 229 | * @param $pattern 规则字符串, 当前允许格式分为三种: 一种为空主机头域名, |
||
| 230 | * 比如 foo.com; 一种是泛域名,比如 *.bar.com; 一种是完全通配符, |
||
| 231 | * 即一个 *; 多个规则之间用;隔开, 比如: foo.com;*.bar.com;sub.foo.com;*.sub.bar.com |
||
| 232 | * @param $source_enabled 源站是否支持,默认为0只给CDN配置, 设置为1表示开启源站防盗链 |
||
| 233 | * |
||
| 234 | * @return mixed 成功返回NULL,失败返回对象Qiniu\Http\Error |
||
| 235 | */ |
||
| 236 | // public function referAntiLeech(){ |
||
| 237 | |||
| 238 | // } |
||
| 239 | |||
| 240 | /** |
||
| 241 | * 增加bucket生命规则 |
||
| 242 | * |
||
| 243 | * @param $bucket 空间名 |
||
| 244 | * @param $name 规则名称 bucket 内唯一,长度小于50,不能为空,只能为 |
||
| 245 | * 字母、数字、下划线 |
||
| 246 | * @param $prefix 同一个 bucket 里面前缀不能重复 |
||
| 247 | * @param $delete_after_days 指定上传文件多少天后删除,指定为0表示不删除, |
||
| 248 | * 大于0表示多少天后删除,需大于 to_line_after_days |
||
| 249 | * @param $to_line_after_days 指定文件上传多少天后转低频存储。指定为0表示 |
||
| 250 | * 不转低频存储,小于0表示上传的文件立即变低频存储 |
||
| 251 | * @return mixed 成功返回NULL,失败返回对象Qiniu\Http\Error |
||
| 252 | */ |
||
| 253 | public function bucketLifecycleRule( |
||
| 280 | |||
| 281 | /** |
||
| 282 | * 更新bucket生命规则 |
||
| 283 | * |
||
| 284 | * @param $bucket 空间名 |
||
| 285 | * @param $name 规则名称 bucket 内唯一,长度小于50,不能为空,只能为字母、 |
||
| 286 | * 数字、下划线 |
||
| 287 | * @param $prefix 同一个 bucket 里面前缀不能重复 |
||
| 288 | * @param $delete_after_days 指定上传文件多少天后删除,指定为0表示不删除, |
||
| 289 | * 大于0表示多少天后删除,需大于 to_line_after_days |
||
| 290 | * @param $to_line_after_days 指定文件上传多少天后转低频存储。指定为0表示不 |
||
| 291 | * 转低频存储,小于0表示上传的文件立即变低频存储 |
||
| 292 | * @return mixed 成功返回NULL,失败返回对象Qiniu\Http\Error |
||
| 293 | */ |
||
| 294 | public function updateBucketLifecycleRule( |
||
| 321 | |||
| 322 | /** |
||
| 323 | * 获取bucket生命规则 |
||
| 324 | * |
||
| 325 | * @param $bucket 空间名 |
||
| 326 | * @return mixed 成功返回NULL,失败返回对象Qiniu\Http\Error |
||
| 327 | */ |
||
| 328 | public function getBucketLifecycleRules($bucket) |
||
| 334 | |||
| 335 | /** |
||
| 336 | * 删除bucket生命规则 |
||
| 337 | * |
||
| 338 | * @param $bucket 空间名 |
||
| 339 | * @param $name 规则名称 bucket 内唯一,长度小于50,不能为空, |
||
| 340 | * 只能为字母、数字、下划线() |
||
| 341 | * @return mixed 成功返回NULL,失败返回对象Qiniu\Http\Error |
||
| 342 | */ |
||
| 343 | public function deleteBucketLifecycleRule($bucket, $name) |
||
| 356 | |||
| 357 | /** |
||
| 358 | * 增加bucket事件通知规则 |
||
| 359 | * |
||
| 360 | * @param $bucket 空间名 |
||
| 361 | * @param $name 规则名称 bucket 内唯一,长度小于50,不能为空, |
||
| 362 | * 只能为字母、数字、下划线() |
||
| 363 | * @param $prefix 同一个 bucket 里面前缀不能重复 |
||
| 364 | * @param $suffix 可选,文件配置的后缀 |
||
| 365 | * @param $event 事件类型,可以指定多个,包括 put,mkfile,delete,copy,move,append, |
||
| 366 | * disable,enable,deleteMarkerCreate |
||
| 367 | * @param $callbackURL 通知URL,可以指定多个,失败依次重试 |
||
| 368 | * @param $access_key 可选,设置的话会对通知请求用对应的ak、sk进行签名 |
||
| 369 | * @param $host 可选,通知请求的host |
||
| 370 | * |
||
| 371 | * @return mixed 成功返回NULL,失败返回对象Qiniu\Http\Error |
||
| 372 | */ |
||
| 373 | public function putBucketEvent( |
||
| 416 | |||
| 417 | /** |
||
| 418 | * 更新bucket事件通知规则 |
||
| 419 | * |
||
| 420 | * @param $bucket 空间名 |
||
| 421 | * @param $name 规则名称 bucket 内唯一,长度小于50,不能为空, |
||
| 422 | * 只能为字母、数字、下划线() |
||
| 423 | * @param $prefix 同一个 bucket 里面前缀不能重复 |
||
| 424 | * @param $suffix 可选,文件配置的后缀 |
||
| 425 | * @param $event 事件类型,可以指定多个,包括 put,mkfile,delete,copy,move,append,disable, |
||
| 426 | * enable,deleteMarkerCreate |
||
| 427 | * @param $callbackURL 通知URL,可以指定多个,失败依次重试 |
||
| 428 | * @param $access_key 可选,设置的话会对通知请求用对应的ak、sk进行签名 |
||
| 429 | * @param $host 可选,通知请求的host |
||
| 430 | * |
||
| 431 | * @return mixed 成功返回NULL,失败返回对象Qiniu\Http\Error |
||
| 432 | */ |
||
| 433 | public function updateBucketEvent( |
||
| 472 | |||
| 473 | /** |
||
| 474 | * 获取bucket事件通知规则 |
||
| 475 | * |
||
| 476 | * @param $bucket 空间名 |
||
| 477 | * @return mixed 成功返回NULL,失败返回对象Qiniu\Http\Error |
||
| 478 | */ |
||
| 479 | public function getBucketEvents($bucket) |
||
| 485 | |||
| 486 | /** |
||
| 487 | * 删除bucket事件通知规则 |
||
| 488 | * |
||
| 489 | * @param $bucket 空间名 |
||
| 490 | * @param $name 规则名称 bucket 内唯一,长度小于50,不能为空, |
||
| 491 | * 只能为字母、数字、下划线 |
||
| 492 | * @return mixed 成功返回NULL,失败返回对象Qiniu\Http\Error |
||
| 493 | */ |
||
| 494 | public function deleteBucketEvent($bucket, $name) |
||
| 507 | |||
| 508 | /** |
||
| 509 | * 设置bucket的跨域信息,最多允许设置10条跨域规则。 |
||
| 510 | * 对于同一个域名如果设置了多条规则,那么按顺序使用第一条匹配的规则去生成返回值。 |
||
| 511 | * 对于简单跨域请求,只匹配 Origin; |
||
| 512 | * allowed_orgin: 允许的域名。必填;支持通配符*;*表示全部匹配;只有第一个*生效; |
||
| 513 | * 需要设置"Scheme";大小写敏感。例如 |
||
| 514 | * 规则:http://*.abc.*.com 请求:"http://test.abc.test.com" 结果:不通过 |
||
| 515 | * 规则:"http://abc.com" 请求:"https://abc.com"/"abc.com" 结果:不通过 |
||
| 516 | * 规则:"abc.com" 请求:"http://abc.com" 结果:不通过 |
||
| 517 | * allowed_method: 允许的方法。必填;不支持通配符;大小写不敏感; |
||
| 518 | * allowed_header: 允许的header。选填;支持通配符*, |
||
| 519 | * 但只能是单独的*,表示允许全部header,其他*不生效; |
||
| 520 | * 空则不允许任何header;大小写不敏感; |
||
| 521 | * exposed_header: 暴露的header。选填;不支持通配符; |
||
| 522 | * X-Log, X-Reqid是默认会暴露的两个header; |
||
| 523 | * 其他的header如果没有设置,则不会暴露;大小写不敏感; |
||
| 524 | * max_age: 结果可以缓存的时间。选填;空则不缓存; |
||
| 525 | * allowed_credentials:该配置不支持设置,默认为true。 |
||
| 526 | * 备注:如果没有设置任何corsRules,那么默认允许所有的跨域请求 |
||
| 527 | */ |
||
| 528 | // public function putCorsRules(string $bucket, array $params) |
||
| 529 | // { |
||
| 530 | // $path = '/corsRules/set/' . $bucket; |
||
| 531 | // $data = json_encode($params); |
||
| 532 | // $info = $this->ucPost($path, $data); |
||
| 533 | // return $info; |
||
| 534 | // } |
||
| 535 | |||
| 536 | /** |
||
| 537 | * 获取bucket的跨域信息 |
||
| 538 | * $bucket 空间名 |
||
| 539 | */ |
||
| 540 | public function getCorsRules($bucket) |
||
| 546 | |||
| 547 | /** |
||
| 548 | * 设置回源规则 |
||
| 549 | * 使用该API设置源站优先级高于/image设置的源站,即IO优先读取source接口设置的源站配置, |
||
| 550 | * 如果存在会忽略/image设置的源站 |
||
| 551 | * Bucket 空间名 |
||
| 552 | * Host(可选)回源Host |
||
| 553 | * RetryCodes(可选),镜像回源时源站返回Code可以重试,最多指定3个,当前只支持4xx错误码重试 |
||
| 554 | * SourceQiniuAK,SourceQiniuSK(可选)如果存在将在回源时对URL进行签名,客户源站可以验证 |
||
| 555 | * 以保证请求来自Qiniu服务器 |
||
| 556 | * Expires(可选) 签名过期时间,如果不设置默认为1小时 |
||
| 557 | * Addr 回源地址,不可重复。 |
||
| 558 | * Weight 权重,范围限制1-100,不填默认为1,回源时会根据所有源的权重值进行源站选择, |
||
| 559 | * 主备源会分开计算. |
||
| 560 | * Backup 是否备用回源,回源优先尝试主源 |
||
| 561 | */ |
||
| 562 | // public function putBucktSourceConfig(array $params) |
||
| 563 | // { |
||
| 564 | // $path = '/mirrorConfig/set'; |
||
| 565 | // $data = json_encode($params); |
||
| 566 | // $info = $this->ucPostV2($path, $data); |
||
| 567 | // return $info; |
||
| 568 | // } |
||
| 569 | |||
| 570 | /** |
||
| 571 | * 获取空间回源配置 |
||
| 572 | */ |
||
| 573 | public function getBucktSourceConfig(array $params) |
||
| 580 | |||
| 581 | /** |
||
| 582 | * 开关原图保护 |
||
| 583 | * mode 为1表示开启原图保护,0表示关闭 |
||
| 584 | */ |
||
| 585 | public function putBucketAccessStyleMode($bucket, $mode) |
||
| 591 | |||
| 592 | /** |
||
| 593 | * 设置私有属性 |
||
| 594 | * private为0表示公开,为1表示私有 |
||
| 595 | */ |
||
| 596 | public function putBucketAccessMode($bucket, $private) |
||
| 602 | |||
| 603 | /** |
||
| 604 | * 设置referer防盗链 |
||
| 605 | * bucket=<BucketName>: bucket 名 |
||
| 606 | * mode=<AntiLeechMode>: |
||
| 607 | * 0: 表示关闭Referer(使用此选项将会忽略以下参数并将恢复默认值); |
||
| 608 | * 1: 表示设置Referer白名单; 2: 表示设置Referer黑名单 |
||
| 609 | * norefer=<NoRefer>: 0: 表示不允许空 Refer 访问; |
||
| 610 | * 1: 表示允许空 Refer 访问 |
||
| 611 | * pattern=<Pattern>: 规则字符串, 当前允许格式分为三种: |
||
| 612 | * 一种为空主机头域名, 比如 foo.com; |
||
| 613 | * 一种是泛域名, 比如 *.bar.com; 一种是完全通配符, 即一个 *; |
||
| 614 | * 多个规则之间用;隔开, 比如: foo.com;*.bar.com;sub.foo.com;*.sub.bar.com |
||
| 615 | * 空主机头域名可以是多级域名,比如 foo.bar.com。 |
||
| 616 | * 多个域名之间不允许夹带空白字符。 |
||
| 617 | * source_enabled=:1 |
||
| 618 | */ |
||
| 619 | public function putReferAntiLeech($bucket, $mode, $norefer, $pattern, $enabled = 1) |
||
| 625 | |||
| 626 | /** |
||
| 627 | * 设置Bucket的maxAge |
||
| 628 | * maxAge为0或者负数表示为默认值(31536000) |
||
| 629 | */ |
||
| 630 | public function putBucketMaxAge($bucket, $maxAge) |
||
| 636 | |||
| 637 | /** |
||
| 638 | * 设置配额 |
||
| 639 | * <bucket>: 空间名称,不支持授权空间 |
||
| 640 | * <size>: 空间存储量配额,参数传入0或不传表示不更改当前配置,传入-1表示取消限额, |
||
| 641 | * 新创建的空间默认没有限额。 |
||
| 642 | * <count>: 空间文件数配额,参数含义同<size> |
||
| 643 | */ |
||
| 644 | public function putBucketQuota($bucket, $size, $count) |
||
| 650 | |||
| 651 | /** |
||
| 652 | * 获取配额 |
||
| 653 | * bucket 空间名称 |
||
| 654 | */ |
||
| 655 | public function getBucketQuota($bucket) |
||
| 661 | |||
| 662 | /** |
||
| 663 | * 获取资源的元信息,但不返回文件内容 |
||
| 664 | * |
||
| 665 | * @param $bucket 待获取信息资源所在的空间 |
||
| 666 | * @param $key 待获取资源的文件名 |
||
| 667 | * |
||
| 668 | * @return array 包含文件信息的数组,类似: |
||
| 669 | * [ |
||
| 670 | * "hash" => "<Hash string>", |
||
| 671 | * "key" => "<Key string>", |
||
| 672 | * "fsize" => <file size>, |
||
| 673 | * "putTime" => "<file modify time>" |
||
| 674 | * "fileType" => <file type> |
||
| 675 | * ] |
||
| 676 | * |
||
| 677 | 6 | * @link http://developer.qiniu.com/docs/v6/api/reference/rs/stat.html |
|
| 678 | */ |
||
| 679 | 6 | public function stat($bucket, $key) |
|
| 684 | |||
| 685 | /** |
||
| 686 | * 删除指定资源 |
||
| 687 | * |
||
| 688 | * @param $bucket 待删除资源所在的空间 |
||
| 689 | * @param $key 待删除资源的文件名 |
||
| 690 | * |
||
| 691 | * @return mixed 成功返回NULL,失败返回对象Qiniu\Http\Error |
||
| 692 | 15 | * @link http://developer.qiniu.com/docs/v6/api/reference/rs/delete.html |
|
| 693 | */ |
||
| 694 | 15 | public function delete($bucket, $key) |
|
| 700 | |||
| 701 | |||
| 702 | /** |
||
| 703 | * 给资源进行重命名,本质为move操作。 |
||
| 704 | * |
||
| 705 | * @param $bucket 待操作资源所在空间 |
||
| 706 | * @param $oldname 待操作资源文件名 |
||
| 707 | * @param $newname 目标资源文件名 |
||
| 708 | * |
||
| 709 | 3 | * @return mixed 成功返回NULL,失败返回对象Qiniu\Http\Error |
|
| 710 | */ |
||
| 711 | 3 | public function rename($bucket, $oldname, $newname) |
|
| 715 | |||
| 716 | /** |
||
| 717 | * 对资源进行复制。 |
||
| 718 | * |
||
| 719 | * @param $from_bucket 待操作资源所在空间 |
||
| 720 | * @param $from_key 待操作资源文件名 |
||
| 721 | * @param $to_bucket 目标资源空间名 |
||
| 722 | * @param $to_key 目标资源文件名 |
||
| 723 | * |
||
| 724 | * @return mixed 成功返回NULL,失败返回对象Qiniu\Http\Error |
||
| 725 | 15 | * @link http://developer.qiniu.com/docs/v6/api/reference/rs/copy.html |
|
| 726 | */ |
||
| 727 | 15 | public function copy($from_bucket, $from_key, $to_bucket, $to_key, $force = false) |
|
| 738 | |||
| 739 | /** |
||
| 740 | * 将资源从一个空间到另一个空间 |
||
| 741 | * |
||
| 742 | * @param $from_bucket 待操作资源所在空间 |
||
| 743 | * @param $from_key 待操作资源文件名 |
||
| 744 | * @param $to_bucket 目标资源空间名 |
||
| 745 | * @param $to_key 目标资源文件名 |
||
| 746 | * |
||
| 747 | * @return mixed 成功返回NULL,失败返回对象Qiniu\Http\Error |
||
| 748 | 3 | * @link http://developer.qiniu.com/docs/v6/api/reference/rs/move.html |
|
| 749 | */ |
||
| 750 | 3 | public function move($from_bucket, $from_key, $to_bucket, $to_key, $force = false) |
|
| 761 | |||
| 762 | /** |
||
| 763 | * 主动修改指定资源的文件元信息 |
||
| 764 | * |
||
| 765 | * @param $bucket 待操作资源所在空间 |
||
| 766 | * @param $key 待操作资源文件名 |
||
| 767 | * @param $mime 待操作文件目标mimeType |
||
| 768 | * |
||
| 769 | * @return mixed 成功返回NULL,失败返回对象Qiniu\Http\Error |
||
| 770 | 3 | * @link http://developer.qiniu.com/docs/v6/api/reference/rs/chgm.html |
|
| 771 | */ |
||
| 772 | 3 | public function changeMime($bucket, $key, $mime) |
|
| 780 | |||
| 781 | |||
| 782 | /** |
||
| 783 | * 修改指定资源的存储类型 |
||
| 784 | * |
||
| 785 | * @param $bucket 待操作资源所在空间 |
||
| 786 | * @param $key 待操作资源文件名 |
||
| 787 | * @param $fileType 待操作文件目标文件类型 |
||
| 788 | * |
||
| 789 | * @return mixed 成功返回NULL,失败返回对象Qiniu\Http\Error |
||
| 790 | * @link https://developer.qiniu.com/kodo/api/3710/modify-the-file-type |
||
| 791 | */ |
||
| 792 | public function changeType($bucket, $key, $fileType) |
||
| 799 | |||
| 800 | /** |
||
| 801 | * 修改指定资源的存储类型 |
||
| 802 | * |
||
| 803 | * @param $bucket 待操作资源所在空间 |
||
| 804 | * @param $key 待操作资源文件名 |
||
| 805 | * @param $day 解冻有效时长,取值范围 1~7 |
||
| 806 | * |
||
| 807 | * @return mixed 成功返回NULL,失败返回对象Qiniu\Http\Error |
||
| 808 | * @link https://developer.qiniu.com/kodo/api/6380/restore-archive |
||
| 809 | */ |
||
| 810 | public function restoreFile($bucket, $key, $day) |
||
| 817 | |||
| 818 | /** |
||
| 819 | * 修改文件的存储状态,即禁用状态和启用状态间的的互相转换 |
||
| 820 | * |
||
| 821 | * @param $bucket 待操作资源所在空间 |
||
| 822 | * @param $key 待操作资源文件名 |
||
| 823 | * @param $status 待操作文件目标文件类型 |
||
| 824 | * |
||
| 825 | * @return mixed 成功返回NULL,失败返回对象Qiniu\Http\Error |
||
| 826 | * @link https://developer.qiniu.com/kodo/api/4173/modify-the-file-status |
||
| 827 | */ |
||
| 828 | public function changeStatus($bucket, $key, $status) |
||
| 835 | |||
| 836 | /** |
||
| 837 | * 从指定URL抓取资源,并将该资源存储到指定空间中 |
||
| 838 | 3 | * |
|
| 839 | * @param $url 指定的URL |
||
| 840 | * @param $bucket 目标资源空间 |
||
| 841 | 3 | * @param $key 目标资源文件名 |
|
| 842 | 3 | * |
|
| 843 | 3 | * @return array 包含已拉取的文件信息。 |
|
| 844 | * 成功时: [ |
||
| 845 | 3 | * [ |
|
| 846 | 3 | * "hash" => "<Hash string>", |
|
| 847 | * "key" => "<Key string>" |
||
| 848 | 3 | * ], |
|
| 849 | 3 | * null |
|
| 850 | * ] |
||
| 851 | * |
||
| 852 | * 失败时: [ |
||
| 853 | * null, |
||
| 854 | * Qiniu/Http/Error |
||
| 855 | * ] |
||
| 856 | * @link http://developer.qiniu.com/docs/v6/api/reference/rs/fetch.html |
||
| 857 | */ |
||
| 858 | public function fetch($url, $bucket, $key = null) |
||
| 871 | 3 | ||
| 872 | /** |
||
| 873 | * 从镜像源站抓取资源到空间中,如果空间中已经存在,则覆盖该资源 |
||
| 874 | * |
||
| 875 | * @param $bucket 待获取资源所在的空间 |
||
| 876 | * @param $key 代获取资源文件名 |
||
| 877 | * |
||
| 878 | * @return mixed 成功返回NULL,失败返回对象Qiniu\Http\Error |
||
| 879 | * @link http://developer.qiniu.com/docs/v6/api/reference/rs/prefetch.html |
||
| 880 | */ |
||
| 881 | public function prefetch($bucket, $key) |
||
| 893 | 12 | ||
| 894 | /** |
||
| 895 | * 在单次请求中进行多个资源管理操作 |
||
| 896 | * |
||
| 897 | * @param $operations 资源管理操作数组 |
||
| 898 | * |
||
| 899 | * @return array 每个资源的处理情况,结果类似: |
||
| 900 | * [ |
||
| 901 | * { "code" => <HttpCode int>, "data" => <Data> }, |
||
| 902 | * { "code" => <HttpCode int> }, |
||
| 903 | * { "code" => <HttpCode int> }, |
||
| 904 | * { "code" => <HttpCode int> }, |
||
| 905 | * { "code" => <HttpCode int>, "data" => { "error": "<ErrorMessage string>" } }, |
||
| 906 | 3 | * ... |
|
| 907 | * ] |
||
| 908 | 3 | * @link http://developer.qiniu.com/docs/v6/api/reference/rs/batch.html |
|
| 909 | 3 | */ |
|
| 910 | 3 | public function batch($operations) |
|
| 915 | |||
| 916 | 3 | /** |
|
| 917 | 3 | * 设置文件的生命周期 |
|
| 918 | * |
||
| 919 | * @param $bucket 设置文件生命周期文件所在的空间 |
||
| 920 | 3 | * @param $key 设置文件生命周期文件的文件名 |
|
| 921 | * @param $days 设置该文件多少天后删除,当$days设置为0时表示取消该文件的生命周期 |
||
| 922 | * |
||
| 923 | 33 | * @return Mixed |
|
| 924 | * @link https://developer.qiniu.com/kodo/api/update-file-lifecycle |
||
| 925 | 33 | */ |
|
| 926 | 33 | public function deleteAfterDays($bucket, $key, $days) |
|
| 933 | |||
| 934 | private function getRsfHost() |
||
| 942 | |||
| 943 | private function getRsHost() |
||
| 951 | |||
| 952 | 27 | private function getApiHost() |
|
| 960 | |||
| 961 | private function getUcHost() |
||
| 969 | |||
| 970 | private function rsPost($path, $body = null) |
||
| 975 | |||
| 976 | private function apiPost($path, $body = null) |
||
| 981 | |||
| 982 | 9 | private function ucPost($path, $body = null) |
|
| 987 | |||
| 988 | 12 | private function ucGet($path) |
|
| 993 | 12 | ||
| 994 | private function apiGet($path) |
||
| 999 | 33 | ||
| 1000 | 33 | private function rsGet($path) |
|
| 1005 | |||
| 1006 | private function get($url) |
||
| 1015 | |||
| 1016 | private function post($url, $body) |
||
| 1026 | |||
| 1027 | 3 | private function ucPostV2($path, $body) |
|
| 1032 | |||
| 1033 | 3 | private function rsPostV2($path, $body) |
|
| 1038 | |||
| 1039 | 6 | private function postV2($url, $body) |
|
| 1050 | |||
| 1051 | 3 | public static function buildBatchCopy($source_bucket, $key_pairs, $target_bucket, $force) |
|
| 1055 | |||
| 1056 | |||
| 1057 | public static function buildBatchRename($bucket, $key_pairs, $force) |
||
| 1061 | |||
| 1062 | |||
| 1063 | public static function buildBatchMove($source_bucket, $key_pairs, $target_bucket, $force) |
||
| 1067 | |||
| 1068 | |||
| 1069 | public static function buildBatchDelete($bucket, $keys) |
||
| 1073 | |||
| 1074 | |||
| 1075 | public static function buildBatchStat($bucket, $keys) |
||
| 1079 | |||
| 1080 | public static function buildBatchDeleteAfterDays($bucket, $key_day_pairs) |
||
| 1088 | |||
| 1089 | public static function buildBatchChangeMime($bucket, $key_mime_pairs) |
||
| 1097 | 9 | ||
| 1098 | 9 | public static function buildBatchChangeType($bucket, $key_type_pairs) |
|
| 1106 | |||
| 1107 | private static function oneKeyBatch($operation, $bucket, $keys) |
||
| 1115 | |||
| 1116 | private static function twoKeyBatch($operation, $source_bucket, $key_pairs, $target_bucket, $force) |
||
| 1133 | } |
||
| 1134 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.