Message.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CatchAdmin [Just Like ~ ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2017~2020 http://catchadmin.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
  8. // +----------------------------------------------------------------------
  9. // | Author: JaguarJack [ njphper@gmail.com ]
  10. // +----------------------------------------------------------------------
  11. namespace catchAdmin\wechat\library\messages;
  12. use think\helper\Str;
  13. abstract class Message
  14. {
  15. protected $message;
  16. public function __construct(array $message)
  17. {
  18. $this->message = $message;
  19. }
  20. /**
  21. * 接收方账号
  22. *
  23. * @time 2020年06月26日
  24. * @return mixed
  25. */
  26. protected function toUserName()
  27. {
  28. return $this->message['ToUserName'];
  29. }
  30. /**
  31. * 发送方账号
  32. *
  33. * @time 2020年06月26日
  34. * @return mixed
  35. */
  36. protected function fromUserName()
  37. {
  38. return $this->message['FromUserName'];
  39. }
  40. abstract public function reply();
  41. /**
  42. * 访问消息内容
  43. *
  44. * @time 2020年06月26日
  45. * @param $name
  46. * @return mixed
  47. */
  48. public function __get($name)
  49. {
  50. // TODO: Implement __get() method.
  51. return $this->message[Str::camel($name)];
  52. }
  53. /**
  54. * 访问消息内容
  55. *
  56. * @time 2020年06月26日
  57. * @param $name
  58. * @param $arguments
  59. * @return mixed
  60. */
  61. public function __call($name, $arguments)
  62. {
  63. // TODO: Implement __call() method.
  64. return $this->message[lcfirst($name)];
  65. }
  66. }