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:
Complex classes like XingeApp 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 XingeApp, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 13 | class XingeApp |
||
| 14 | { |
||
| 15 | const DEVICE_ALL = 0; |
||
| 16 | const DEVICE_BROWSER = 1; |
||
| 17 | const DEVICE_PC = 2; |
||
| 18 | const DEVICE_ANDROID = 3; |
||
| 19 | const DEVICE_IOS = 4; |
||
| 20 | const DEVICE_WINPHONE = 5; |
||
| 21 | |||
| 22 | const IOSENV_PROD = 1; |
||
| 23 | const IOSENV_DEV = 2; |
||
| 24 | |||
| 25 | const IOS_MIN_ID = 2200000000; |
||
| 26 | |||
| 27 | public function __construct($accessId, $secretKey) |
||
| 34 | |||
| 35 | public function __destruct() |
||
| 38 | |||
| 39 | /** |
||
| 40 | * 使用默认设置推送消息给单个android设备. |
||
| 41 | */ |
||
| 42 | public static function PushTokenAndroid($accessId, $secretKey, $title, $content, $token) |
||
| 57 | |||
| 58 | /** |
||
| 59 | * 使用默认设置推送消息给单个ios设备. |
||
| 60 | */ |
||
| 61 | public static function PushTokenIos($accessId, $secretKey, $content, $token, $environment) |
||
| 70 | |||
| 71 | /** |
||
| 72 | * 使用默认设置推送消息给单个android版账户. |
||
| 73 | */ |
||
| 74 | View Code Duplication | public static function PushAccountAndroid($accessId, $secretKey, $title, $content, $account) |
|
| 89 | |||
| 90 | /** |
||
| 91 | * 使用默认设置推送消息给单个ios版账户. |
||
| 92 | */ |
||
| 93 | View Code Duplication | public static function PushAccountIos($accessId, $secretKey, $content, $account, $environment) |
|
| 102 | |||
| 103 | /** |
||
| 104 | * 使用默认设置推送消息给所有设备android版. |
||
| 105 | */ |
||
| 106 | View Code Duplication | public static function PushAllAndroid($accessId, $secretKey, $title, $content) |
|
| 121 | |||
| 122 | /** |
||
| 123 | * 使用默认设置推送消息给所有设备ios版. |
||
| 124 | */ |
||
| 125 | View Code Duplication | public static function PushAllIos($accessId, $secretKey, $content, $environment) |
|
| 134 | |||
| 135 | /** |
||
| 136 | * 使用默认设置推送消息给标签选中设备android版. |
||
| 137 | */ |
||
| 138 | View Code Duplication | public static function PushTagAndroid($accessId, $secretKey, $title, $content, $tag) |
|
| 153 | |||
| 154 | /** |
||
| 155 | * 使用默认设置推送消息给标签选中设备ios版. |
||
| 156 | */ |
||
| 157 | View Code Duplication | public static function PushTagIos($accessId, $secretKey, $content, $tag, $environment) |
|
| 166 | |||
| 167 | /** |
||
| 168 | * 推送消息给单个设备. |
||
| 169 | */ |
||
| 170 | View Code Duplication | public function PushSingleDevice($deviceToken, $message, $environment = 0) |
|
| 171 | { |
||
| 172 | $ret = ['ret_code' => -1, 'err_msg' => 'message not valid']; |
||
| 173 | |||
| 174 | if (! ($message instanceof Message) && ! ($message instanceof MessageIOS)) { |
||
| 175 | return $ret; |
||
| 176 | } |
||
| 177 | if (! $this->ValidateMessageType($message)) { |
||
| 178 | $ret['err_msg'] = 'message type not fit accessId'; |
||
| 179 | |||
| 180 | return $ret; |
||
| 181 | } |
||
| 182 | if ($message instanceof MessageIOS) { |
||
| 183 | if ($environment != self::IOSENV_DEV && $environment != self::IOSENV_PROD) { |
||
| 184 | $ret['err_msg'] = 'ios message environment invalid'; |
||
| 185 | |||
| 186 | return $ret; |
||
| 187 | } |
||
| 188 | } |
||
| 189 | if (! $message->isValid()) { |
||
| 190 | return $ret; |
||
| 191 | } |
||
| 192 | $params = []; |
||
| 193 | $params['access_id'] = $this->accessId; |
||
| 194 | $params['expire_time'] = $message->getExpireTime(); |
||
| 195 | $params['send_time'] = $message->getSendTime(); |
||
| 196 | if ($message instanceof Message) { |
||
| 197 | $params['multi_pkg'] = $message->getMultiPkg(); |
||
| 198 | } |
||
| 199 | $params['device_token'] = $deviceToken; |
||
| 200 | $params['message_type'] = $message->getType(); |
||
| 201 | $params['message'] = $message->toJson(); |
||
| 202 | $params['timestamp'] = time(); |
||
| 203 | $params['environment'] = $environment; |
||
| 204 | |||
| 205 | return $this->callRestful(self::RESTAPI_PUSHSINGLEDEVICE, $params); |
||
| 206 | } |
||
| 207 | |||
| 208 | /** |
||
| 209 | * 推送消息给单个账户. |
||
| 210 | */ |
||
| 211 | public function PushSingleAccount($deviceType, $account, $message, $environment = 0) |
||
| 212 | { |
||
| 213 | $ret = ['ret_code' => -1]; |
||
| 214 | View Code Duplication | if (! is_int($deviceType) || $deviceType < 0 || $deviceType > 5) { |
|
| 215 | $ret['err_msg'] = 'deviceType not valid'; |
||
| 216 | |||
| 217 | return $ret; |
||
| 218 | } |
||
| 219 | if (! is_string($account) || empty($account)) { |
||
| 220 | $ret['err_msg'] = 'account not valid'; |
||
| 221 | |||
| 222 | return $ret; |
||
| 223 | } |
||
| 224 | if (! ($message instanceof Message) && ! ($message instanceof MessageIOS)) { |
||
| 225 | $ret['err_msg'] = 'message is not android or ios'; |
||
| 226 | |||
| 227 | return $ret; |
||
| 228 | } |
||
| 229 | if (! $this->ValidateMessageType($message)) { |
||
| 230 | $ret['err_msg'] = 'message type not fit accessId'; |
||
| 231 | |||
| 232 | return $ret; |
||
| 233 | } |
||
| 234 | if ($message instanceof MessageIOS) { |
||
| 235 | if ($environment != self::IOSENV_DEV && $environment != self::IOSENV_PROD) { |
||
| 236 | $ret['err_msg'] = 'ios message environment invalid'; |
||
| 237 | |||
| 238 | return $ret; |
||
| 239 | } |
||
| 240 | } |
||
| 241 | if (! $message->isValid()) { |
||
| 242 | $ret['err_msg'] = 'message not valid'; |
||
| 243 | |||
| 244 | return $ret; |
||
| 245 | } |
||
| 246 | $params = []; |
||
| 247 | $params['access_id'] = $this->accessId; |
||
| 248 | $params['expire_time'] = $message->getExpireTime(); |
||
| 249 | $params['send_time'] = $message->getSendTime(); |
||
| 250 | if ($message instanceof Message) { |
||
| 251 | $params['multi_pkg'] = $message->getMultiPkg(); |
||
| 252 | } |
||
| 253 | $params['device_type'] = $deviceType; |
||
| 254 | $params['account'] = $account; |
||
| 255 | $params['message_type'] = $message->getType(); |
||
| 256 | $params['message'] = $message->toJson(); |
||
| 257 | $params['timestamp'] = time(); |
||
| 258 | $params['environment'] = $environment; |
||
| 259 | |||
| 260 | return $this->callRestful(self::RESTAPI_PUSHSINGLEACCOUNT, $params); |
||
| 261 | } |
||
| 262 | |||
| 263 | /** |
||
| 264 | * 推送消息给多个账户. |
||
| 265 | */ |
||
| 266 | public function PushAccountList($deviceType, $accountList, $message, $environment = 0) |
||
| 267 | { |
||
| 268 | $ret = ['ret_code' => -1]; |
||
| 269 | View Code Duplication | if (! is_int($deviceType) || $deviceType < 0 || $deviceType > 5) { |
|
| 270 | $ret['err_msg'] = 'deviceType not valid'; |
||
| 271 | |||
| 272 | return $ret; |
||
| 273 | } |
||
| 274 | if (! is_array($accountList) || empty($accountList)) { |
||
| 275 | $ret['err_msg'] = 'accountList not valid'; |
||
| 276 | |||
| 277 | return $ret; |
||
| 278 | } |
||
| 279 | if (! ($message instanceof Message) && ! ($message instanceof MessageIOS)) { |
||
| 280 | $ret['err_msg'] = 'message is not android or ios'; |
||
| 281 | |||
| 282 | return $ret; |
||
| 283 | } |
||
| 284 | if (! $this->ValidateMessageType($message)) { |
||
| 285 | $ret['err_msg'] = 'message type not fit accessId'; |
||
| 286 | |||
| 287 | return $ret; |
||
| 288 | } |
||
| 289 | if ($message instanceof MessageIOS) { |
||
| 290 | if ($environment != self::IOSENV_DEV && $environment != self::IOSENV_PROD) { |
||
| 291 | $ret['err_msg'] = 'ios message environment invalid'; |
||
| 292 | |||
| 293 | return $ret; |
||
| 294 | } |
||
| 295 | } |
||
| 296 | if (! $message->isValid()) { |
||
| 297 | $ret['err_msg'] = 'message not valid'; |
||
| 298 | |||
| 299 | return $ret; |
||
| 300 | } |
||
| 301 | $params = []; |
||
| 302 | $params['access_id'] = $this->accessId; |
||
| 303 | $params['expire_time'] = $message->getExpireTime(); |
||
| 304 | if ($message instanceof Message) { |
||
| 305 | $params['multi_pkg'] = $message->getMultiPkg(); |
||
| 306 | } |
||
| 307 | $params['device_type'] = $deviceType; |
||
| 308 | $params['account_list'] = json_encode($accountList); |
||
| 309 | $params['message_type'] = $message->getType(); |
||
| 310 | $params['message'] = $message->toJson(); |
||
| 311 | $params['timestamp'] = time(); |
||
| 312 | $params['environment'] = $environment; |
||
| 313 | |||
| 314 | return $this->callRestful(self::RESTAPI_PUSHACCOUNTLIST, $params); |
||
| 315 | } |
||
| 316 | |||
| 317 | /** |
||
| 318 | * 推送消息给APP所有设备. |
||
| 319 | */ |
||
| 320 | public function PushAllDevices($deviceType, $message, $environment = 0) |
||
| 321 | { |
||
| 322 | $ret = ['ret_code' => -1, 'err_msg' => 'message not valid']; |
||
| 323 | View Code Duplication | if (! is_int($deviceType) || $deviceType < 0 || $deviceType > 5) { |
|
| 324 | $ret['err_msg'] = 'deviceType not valid'; |
||
| 325 | |||
| 326 | return $ret; |
||
| 327 | } |
||
| 328 | |||
| 329 | if (! ($message instanceof Message) && ! ($message instanceof MessageIOS)) { |
||
| 330 | return $ret; |
||
| 331 | } |
||
| 332 | if (! $this->ValidateMessageType($message)) { |
||
| 333 | $ret['err_msg'] = 'message type not fit accessId'; |
||
| 334 | |||
| 335 | return $ret; |
||
| 336 | } |
||
| 337 | if ($message instanceof MessageIOS) { |
||
| 338 | if ($environment != self::IOSENV_DEV && $environment != self::IOSENV_PROD) { |
||
| 339 | $ret['err_msg'] = 'ios message environment invalid'; |
||
| 340 | |||
| 341 | return $ret; |
||
| 342 | } |
||
| 343 | } |
||
| 344 | if (! $message->isValid()) { |
||
| 345 | return $ret; |
||
| 346 | } |
||
| 347 | $params = []; |
||
| 348 | $params['access_id'] = $this->accessId; |
||
| 349 | $params['expire_time'] = $message->getExpireTime(); |
||
| 350 | $params['send_time'] = $message->getSendTime(); |
||
| 351 | if ($message instanceof Message) { |
||
| 352 | $params['multi_pkg'] = $message->getMultiPkg(); |
||
| 353 | } |
||
| 354 | $params['device_type'] = $deviceType; |
||
| 355 | $params['message_type'] = $message->getType(); |
||
| 356 | $params['message'] = $message->toJson(); |
||
| 357 | $params['timestamp'] = time(); |
||
| 358 | $params['environment'] = $environment; |
||
| 359 | |||
| 360 | View Code Duplication | if (! is_null($message->getLoopInterval()) && $message->getLoopInterval() > 0 |
|
| 361 | && ! is_null($message->getLoopTimes()) && $message->getLoopTimes() > 0 |
||
| 362 | ) { |
||
| 363 | $params['loop_interval'] = $message->getLoopInterval(); |
||
| 364 | $params['loop_times'] = $message->getLoopTimes(); |
||
| 365 | } |
||
| 366 | //var_dump($params); |
||
| 367 | |||
| 368 | return $this->callRestful(self::RESTAPI_PUSHALLDEVICE, $params); |
||
| 369 | } |
||
| 370 | |||
| 371 | /** |
||
| 372 | * 推送消息给指定tags的设备 |
||
| 373 | * 若要推送的tagList只有一项,则tagsOp应为OR. |
||
| 374 | */ |
||
| 375 | public function PushTags($deviceType, $tagList, $tagsOp, $message, $environment = 0) |
||
| 376 | { |
||
| 377 | $ret = ['ret_code' => -1, 'err_msg' => 'message not valid']; |
||
| 378 | View Code Duplication | if (! is_int($deviceType) || $deviceType < 0 || $deviceType > 5) { |
|
| 379 | $ret['err_msg'] = 'deviceType not valid'; |
||
| 380 | |||
| 381 | return $ret; |
||
| 382 | } |
||
| 383 | if (! is_array($tagList) || empty($tagList)) { |
||
| 384 | $ret['err_msg'] = 'tagList not valid'; |
||
| 385 | |||
| 386 | return $ret; |
||
| 387 | } |
||
| 388 | if (! is_string($tagsOp) || ($tagsOp != 'AND' && $tagsOp != 'OR')) { |
||
| 389 | $ret['err_msg'] = 'tagsOp not valid'; |
||
| 390 | |||
| 391 | return $ret; |
||
| 392 | } |
||
| 393 | |||
| 394 | if (! ($message instanceof Message) && ! ($message instanceof MessageIOS)) { |
||
| 395 | return $ret; |
||
| 396 | } |
||
| 397 | if (! $this->ValidateMessageType($message)) { |
||
| 398 | $ret['err_msg'] = 'message type not fit accessId'; |
||
| 399 | |||
| 400 | return $ret; |
||
| 401 | } |
||
| 402 | if ($message instanceof MessageIOS) { |
||
| 403 | if ($environment != self::IOSENV_DEV && $environment != self::IOSENV_PROD) { |
||
| 404 | $ret['err_msg'] = 'ios message environment invalid'; |
||
| 405 | |||
| 406 | return $ret; |
||
| 407 | } |
||
| 408 | } |
||
| 409 | if (! $message->isValid()) { |
||
| 410 | return $ret; |
||
| 411 | } |
||
| 412 | |||
| 413 | $params = []; |
||
| 414 | $params['access_id'] = $this->accessId; |
||
| 415 | $params['expire_time'] = $message->getExpireTime(); |
||
| 416 | $params['send_time'] = $message->getSendTime(); |
||
| 417 | if ($message instanceof Message) { |
||
| 418 | $params['multi_pkg'] = $message->getMultiPkg(); |
||
| 419 | } |
||
| 420 | $params['device_type'] = $deviceType; |
||
| 421 | $params['message_type'] = $message->getType(); |
||
| 422 | $params['tags_list'] = json_encode($tagList); |
||
| 423 | $params['tags_op'] = $tagsOp; |
||
| 424 | $params['message'] = $message->toJson(); |
||
| 425 | $params['timestamp'] = time(); |
||
| 426 | $params['environment'] = $environment; |
||
| 427 | |||
| 428 | View Code Duplication | if (! is_null($message->getLoopInterval()) && $message->getLoopInterval() > 0 |
|
| 429 | && ! is_null($message->getLoopTimes()) && $message->getLoopTimes() > 0 |
||
| 430 | ) { |
||
| 431 | $params['loop_interval'] = $message->getLoopInterval(); |
||
| 432 | $params['loop_times'] = $message->getLoopTimes(); |
||
| 433 | } |
||
| 434 | |||
| 435 | return $this->callRestful(self::RESTAPI_PUSHTAGS, $params); |
||
| 436 | } |
||
| 437 | |||
| 438 | /** |
||
| 439 | * 创建批量推送任务 |
||
| 440 | */ |
||
| 441 | View Code Duplication | public function CreateMultipush($message, $environment = 0) |
|
| 442 | { |
||
| 443 | $ret = ['ret_code' => -1]; |
||
| 444 | if (! ($message instanceof Message) && ! ($message instanceof MessageIOS)) { |
||
| 445 | $ret['err_msg'] = 'message is not android or ios'; |
||
| 446 | |||
| 447 | return $ret; |
||
| 448 | } |
||
| 449 | if (! $this->ValidateMessageType($message)) { |
||
| 450 | $ret['err_msg'] = 'message type not fit accessId'; |
||
| 451 | |||
| 452 | return $ret; |
||
| 453 | } |
||
| 454 | if ($message instanceof MessageIOS) { |
||
| 455 | if ($environment != self::IOSENV_DEV && $environment != self::IOSENV_PROD) { |
||
| 456 | $ret['err_msg'] = 'ios message environment invalid'; |
||
| 457 | |||
| 458 | return $ret; |
||
| 459 | } |
||
| 460 | } |
||
| 461 | if (! $message->isValid()) { |
||
| 462 | $ret['err_msg'] = 'message not valid'; |
||
| 463 | |||
| 464 | return $ret; |
||
| 465 | } |
||
| 466 | $params = []; |
||
| 467 | $params['access_id'] = $this->accessId; |
||
| 468 | $params['expire_time'] = $message->getExpireTime(); |
||
| 469 | if ($message instanceof Message) { |
||
| 470 | $params['multi_pkg'] = $message->getMultiPkg(); |
||
| 471 | } |
||
| 472 | $params['message_type'] = $message->getType(); |
||
| 473 | $params['message'] = $message->toJson(); |
||
| 474 | $params['timestamp'] = time(); |
||
| 475 | $params['environment'] = $environment; |
||
| 476 | |||
| 477 | return $this->callRestful(self::RESTAPI_CREATEMULTIPUSH, $params); |
||
| 478 | } |
||
| 479 | |||
| 480 | /** |
||
| 481 | * 按帐号大批量推送 |
||
| 482 | */ |
||
| 483 | View Code Duplication | public function PushAccountListMultiple($pushId, $accountList) |
|
| 505 | |||
| 506 | /** |
||
| 507 | * 按Token大批量推送 |
||
| 508 | */ |
||
| 509 | View Code Duplication | public function PushDeviceListMultiple($pushId, $deviceList) |
|
| 531 | |||
| 532 | /** |
||
| 533 | * 查询消息推送状态 |
||
| 534 | * @param array $pushIdList pushId(string)数组 |
||
| 535 | */ |
||
| 536 | public function QueryPushStatus($pushIdList) |
||
| 537 | { |
||
| 538 | $ret = ['ret_code' => -1]; |
||
| 539 | $idList = []; |
||
| 540 | if (! is_array($pushIdList) || empty($pushIdList)) { |
||
| 541 | $ret['err_msg'] = 'pushIdList not valid'; |
||
| 542 | |||
| 543 | return $ret; |
||
| 544 | } |
||
| 545 | foreach ($pushIdList as $pushId) { |
||
| 546 | $idList[] = ['push_id' => $pushId]; |
||
| 547 | } |
||
| 548 | $params = []; |
||
| 549 | $params['access_id'] = $this->accessId; |
||
| 550 | $params['push_ids'] = json_encode($idList); |
||
| 551 | $params['timestamp'] = time(); |
||
| 552 | |||
| 553 | return $this->callRestful(self::RESTAPI_QUERYPUSHSTATUS, $params); |
||
| 554 | } |
||
| 555 | |||
| 556 | /** |
||
| 557 | * 查询应用覆盖的设备数. |
||
| 558 | */ |
||
| 559 | View Code Duplication | public function QueryDeviceCount() |
|
| 567 | |||
| 568 | /** |
||
| 569 | * 查询应用标签. |
||
| 570 | */ |
||
| 571 | View Code Duplication | public function QueryTags($start = 0, $limit = 100) |
|
| 587 | |||
| 588 | /** |
||
| 589 | * 查询标签下token数量. |
||
| 590 | */ |
||
| 591 | View Code Duplication | public function QueryTagTokenNum($tag) |
|
| 606 | |||
| 607 | /** |
||
| 608 | * 查询token的标签. |
||
| 609 | */ |
||
| 610 | View Code Duplication | public function QueryTokenTags($deviceToken) |
|
| 625 | |||
| 626 | /** |
||
| 627 | * 取消定时发送 |
||
| 628 | */ |
||
| 629 | View Code Duplication | public function CancelTimingPush($pushId) |
|
| 644 | |||
| 645 | //json转换为数组 |
||
| 646 | protected function json2Array($json) |
||
| 652 | |||
| 653 | protected function callRestful($url, $params) |
||
| 664 | |||
| 665 | private function ValidateToken($token) |
||
| 673 | |||
| 674 | View Code Duplication | public function InitParams() |
|
| 682 | |||
| 683 | View Code Duplication | public function BatchSetTag($tagTokenPairs) |
|
| 684 | { |
||
| 685 | $ret = ['ret_code' => -1]; |
||
| 686 | |||
| 687 | foreach ($tagTokenPairs as $pair) { |
||
| 688 | if (! ($pair instanceof TagTokenPair)) { |
||
| 689 | $ret['err_msg'] = 'tag-token pair type error!'; |
||
| 690 | |||
| 691 | return $ret; |
||
| 692 | } |
||
| 693 | if (! $this->ValidateToken($pair->token)) { |
||
| 694 | $ret['err_msg'] = sprintf('invalid token %s', $pair->token); |
||
| 695 | |||
| 696 | return $ret; |
||
| 697 | } |
||
| 698 | } |
||
| 699 | $params = $this->InitParams(); |
||
| 700 | |||
| 701 | $tag_token_list = []; |
||
| 702 | foreach ($tagTokenPairs as $pair) { |
||
| 703 | array_push($tag_token_list, [$pair->tag, $pair->token]); |
||
| 704 | } |
||
| 705 | $params['tag_token_list'] = json_encode($tag_token_list); |
||
| 706 | |||
| 707 | return $this->callRestful(self::RESTAPI_BATCHSETTAG, $params); |
||
| 708 | } |
||
| 709 | |||
| 710 | View Code Duplication | public function BatchDelTag($tagTokenPairs) |
|
| 711 | { |
||
| 712 | $ret = ['ret_code' => -1]; |
||
| 713 | |||
| 714 | foreach ($tagTokenPairs as $pair) { |
||
| 715 | if (! ($pair instanceof TagTokenPair)) { |
||
| 716 | $ret['err_msg'] = 'tag-token pair type error!'; |
||
| 717 | |||
| 718 | return $ret; |
||
| 719 | } |
||
| 720 | if (! $this->ValidateToken($pair->token)) { |
||
| 721 | $ret['err_msg'] = sprintf('invalid token %s', $pair->token); |
||
| 722 | |||
| 723 | return $ret; |
||
| 724 | } |
||
| 725 | } |
||
| 726 | $params = $this->InitParams(); |
||
| 727 | |||
| 728 | $tag_token_list = []; |
||
| 729 | foreach ($tagTokenPairs as $pair) { |
||
| 730 | array_push($tag_token_list, [$pair->tag, $pair->token]); |
||
| 731 | } |
||
| 732 | $params['tag_token_list'] = json_encode($tag_token_list); |
||
| 733 | |||
| 734 | return $this->callRestful(self::RESTAPI_BATCHDELTAG, $params); |
||
| 735 | } |
||
| 736 | |||
| 737 | View Code Duplication | public function QueryInfoOfToken($deviceToken) |
|
| 752 | |||
| 753 | View Code Duplication | public function QueryTokensOfAccount($account) |
|
| 768 | |||
| 769 | View Code Duplication | public function DeleteTokenOfAccount($account, $deviceToken) |
|
| 785 | |||
| 786 | View Code Duplication | public function DeleteAllTokensOfAccount($account) |
|
| 801 | |||
| 802 | private function ValidateMessageType($message) |
||
| 812 | |||
| 813 | public $accessId = ''; //应用的接入Id |
||
| 814 | public $secretKey = ''; //应用的skey |
||
| 815 | |||
| 816 | const RESTAPI_PUSHSINGLEDEVICE = 'http://openapi.xg.qq.com/v2/push/single_device'; |
||
| 817 | const RESTAPI_PUSHSINGLEACCOUNT = 'http://openapi.xg.qq.com/v2/push/single_account'; |
||
| 818 | const RESTAPI_PUSHACCOUNTLIST = 'http://openapi.xg.qq.com/v2/push/account_list'; |
||
| 819 | const RESTAPI_PUSHALLDEVICE = 'http://openapi.xg.qq.com/v2/push/all_device'; |
||
| 820 | const RESTAPI_PUSHTAGS = 'http://openapi.xg.qq.com/v2/push/tags_device'; |
||
| 821 | const RESTAPI_QUERYPUSHSTATUS = 'http://openapi.xg.qq.com/v2/push/get_msg_status'; |
||
| 822 | const RESTAPI_QUERYDEVICECOUNT = 'http://openapi.xg.qq.com/v2/application/get_app_device_num'; |
||
| 823 | const RESTAPI_QUERYTAGS = 'http://openapi.xg.qq.com/v2/tags/query_app_tags'; |
||
| 824 | const RESTAPI_CANCELTIMINGPUSH = 'http://openapi.xg.qq.com/v2/push/cancel_timing_task'; |
||
| 825 | const RESTAPI_BATCHSETTAG = 'http://openapi.xg.qq.com/v2/tags/batch_set'; |
||
| 826 | const RESTAPI_BATCHDELTAG = 'http://openapi.xg.qq.com/v2/tags/batch_del'; |
||
| 827 | const RESTAPI_QUERYTOKENTAGS = 'http://openapi.xg.qq.com/v2/tags/query_token_tags'; |
||
| 828 | const RESTAPI_QUERYTAGTOKENNUM = 'http://openapi.xg.qq.com/v2/tags/query_tag_token_num'; |
||
| 829 | const RESTAPI_CREATEMULTIPUSH = 'http://openapi.xg.qq.com/v2/push/create_multipush'; |
||
| 830 | const RESTAPI_PUSHACCOUNTLISTMULTIPLE = 'http://openapi.xg.qq.com/v2/push/account_list_multiple'; |
||
| 831 | const RESTAPI_PUSHDEVICELISTMULTIPLE = 'http://openapi.xg.qq.com/v2/push/device_list_multiple'; |
||
| 832 | const RESTAPI_QUERYINFOOFTOKEN = 'http://openapi.xg.qq.com/v2/application/get_app_token_info'; |
||
| 833 | const RESTAPI_QUERYTOKENSOFACCOUNT = 'http://openapi.xg.qq.com/v2/application/get_app_account_tokens'; |
||
| 834 | const RESTAPI_DELETETOKENOFACCOUNT = 'http://openapi.xg.qq.com/v2/application/del_app_account_tokens'; |
||
| 835 | const RESTAPI_DELETEALLTOKENSOFACCOUNT = 'http://openapi.xg.qq.com/v2/application/del_app_account_all_tokens'; |
||
| 836 | } |
||
| 837 | |||
| 1812 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.