InstanceAppRingTone.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace App\Libs\Push\HuaWei\Admin\Msg\InstanceApp;
  3. use App\Libs\Push\HuaWei\Admin\Constants;
  4. use App\Libs\Push\HuaWei\Admin\PushLogConfig;
  5. class InstanceAppRingTone
  6. {
  7. private $vibration;
  8. private $breathLight;
  9. private $fields;
  10. public function __construct()
  11. {
  12. $this->fields = array();
  13. }
  14. public function vibration($value)
  15. {
  16. $this->vibration = $value;
  17. }
  18. public function breathLight($value)
  19. {
  20. $this->breathLight = $value;
  21. }
  22. public function getFields()
  23. {
  24. $result = "{";
  25. foreach ($this->fields as $key => $value) {
  26. $result = $result . $key . ":" . json_encode($value) . ",";
  27. PushLogConfig::getSingleInstance()->LogMessage('[' . __CLASS__ . '][result:' . $result, Constants::HW_PUSH_LOG_DEBUG_LEVEL);
  28. }
  29. if (strlen($result) > 1) {
  30. $result = rtrim($result, ",");
  31. }
  32. $result = $result . "}";
  33. return $result;
  34. }
  35. public function buildFields()
  36. {
  37. $keys = array(
  38. 'vibration',
  39. 'breathLight'
  40. );
  41. foreach ($keys as $key) {
  42. PushLogConfig::getSingleInstance()->LogMessage('[' . __CLASS__ . '][key:' . $key . '][value:' . json_encode($this->$key) . ']', Constants::HW_PUSH_LOG_DEBUG_LEVEL);
  43. if (isset($this->$key)) {
  44. $this->fields[$key] = $this->$key;
  45. }
  46. }
  47. PushLogConfig::getSingleInstance()->LogMessage('[' . __CLASS__ . '][buildFields result:' . json_encode($this->fields), Constants::HW_PUSH_LOG_DEBUG_LEVEL);
  48. }
  49. }