Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 1 | <?php |
||
| 12 | class MaterialApi extends BaseApi |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * 获取素材列表. |
||
| 16 | * |
||
| 17 | * @param string $type 获取素材类型, |
||
| 18 | * @param $type $offset 偏移 , |
||
|
|
|||
| 19 | * @param $type $count 数量 不能大于20 |
||
| 20 | * |
||
| 21 | * @return array. 注 返回值为图文(news)时 无法获得文章的正文 |
||
| 22 | */ |
||
| 23 | public function batchget($type = 'image', $offset = 0, $count = 20) |
||
| 39 | |||
| 40 | /** |
||
| 41 | * 上传图文素材. |
||
| 42 | * |
||
| 43 | * @param array $info 图文素材的信息, title 标题,thumb_media_id 封面图片ID,author 作者,digest 摘要,show_cover_pic 是否显示封面,content 内容支持html少于2万字符 小于1M,content_source_url 点击 阅读原文的url |
||
| 44 | * |
||
| 45 | * @return string. 成功返回mediaid |
||
| 46 | */ |
||
| 47 | View Code Duplication | public function addNews($info) |
|
| 61 | |||
| 62 | /** |
||
| 63 | * 新增永久素材. |
||
| 64 | * |
||
| 65 | * @param string $file 媒体文件路径 |
||
| 66 | * @param string $type 文件类型 (video,image,voice,thumb) |
||
| 67 | * |
||
| 68 | * @return array. 媒体文件ID 获取地址 https://mmbiz.qlogo.cn/mmbiz/NdxGKqW8jE9GbAqUEPdSgSvbUbProSmE8NbUFwIYnp0Duibs611ZsCLza6b2dS8Ex3CO5dtv0u1HP9QY32djCxA/0?wx_fmt=jpeg 视频素材 官方接口也无法上传 |
||
| 69 | */ |
||
| 70 | public function add($file, $type = "image", $info = []) |
||
| 110 | |||
| 111 | /** |
||
| 112 | * 获取 永久素材.通常为图文素材 其他素材可以在GetMaterialList获取对应地址 |
||
| 113 | * |
||
| 114 | * @param string $media_id 素材ID |
||
| 115 | * |
||
| 116 | * @return array. |
||
| 117 | */ |
||
| 118 | View Code Duplication | public function get($media_id) |
|
| 134 | |||
| 135 | /** |
||
| 136 | * 删除永久素材. |
||
| 137 | * |
||
| 138 | * @param string $media_id 素材ID |
||
| 139 | * |
||
| 140 | * @return bool. 成功返回ok |
||
| 141 | */ |
||
| 142 | View Code Duplication | public function del($media_id) |
|
| 158 | |||
| 159 | /** |
||
| 160 | * 修改永久素材. |
||
| 161 | * |
||
| 162 | * @param string $media_id 素材ID,$info 保存信息,$index 多图文素材时才有意义 更新位置 |
||
| 163 | * |
||
| 164 | * @return bool. 成功返回ok |
||
| 165 | */ |
||
| 166 | public function updateNews($media_id, $articles, $index = 0) |
||
| 184 | |||
| 185 | /** |
||
| 186 | * 获取素材总数. |
||
| 187 | * |
||
| 188 | * @return array. |
||
| 189 | */ |
||
| 190 | public function getCount() |
||
| 198 | } |
||
| 199 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.