Receiver.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace WeWork\Message;
  3. class Receiver
  4. {
  5. /**
  6. * @var array
  7. */
  8. private $receiver;
  9. /**
  10. * @param string|array $user
  11. * @return void
  12. */
  13. public function setUser($user): void
  14. {
  15. $this->set('touser', $user);
  16. }
  17. /**
  18. * @param string|array $party
  19. * @return void
  20. */
  21. public function setParty($party): void
  22. {
  23. $this->set('toparty', $party);
  24. }
  25. /**
  26. * @param string|array $tag
  27. * @return void
  28. */
  29. public function setTag($tag): void
  30. {
  31. $this->set('totag', $tag);
  32. }
  33. /**
  34. * @return array
  35. */
  36. public function get(): array
  37. {
  38. return $this->receiver;
  39. }
  40. /**
  41. * @param string $key
  42. * @param mixed $value
  43. * @return void
  44. */
  45. private function set(string $key, $value): void
  46. {
  47. if (is_array($value)) {
  48. $value = implode('|', $value);
  49. }
  50. $this->receiver[$key] = $value;
  51. }
  52. }