ApnsHmsOptions.php 950 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace App\Libs\Push\HuaWei\Admin\Msg\Apns;
  3. use Exception;
  4. class ApnsHmsOptions
  5. {
  6. private $target_user_type;
  7. public function getFields()
  8. {
  9. return $this->fields;
  10. }
  11. public function target_user_type($value)
  12. {
  13. $this->target_user_type = $value;
  14. }
  15. public function buildFields()
  16. {
  17. try {
  18. $this->check_parameter();
  19. } catch (Exception $e) {
  20. echo $e;
  21. }
  22. $keys = array(
  23. 'target_user_type'
  24. );
  25. foreach ($keys as $key) {
  26. if (isset($this->$key)) {
  27. $this->fields[$key] = $this->$key;
  28. }
  29. }
  30. }
  31. private function check_parameter()
  32. {
  33. if (!empty($this->target_user_type)
  34. && !in_array($this->target_user_type, array(1, 2, 3))) {
  35. throw new Exception("target_user_type range TEST_USER:1,FORMAL_USER:2,VOIP_USER:3");
  36. }
  37. }
  38. }