Article.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. namespace WeWork\Message;
  3. class Article implements ResponseMessageInterface, ReplyMessageInterface
  4. {
  5. /**
  6. * @var string
  7. */
  8. private $title;
  9. /**
  10. * @var string
  11. */
  12. private $description;
  13. /**
  14. * @var string
  15. */
  16. private $url;
  17. /**
  18. * @var string
  19. */
  20. private $picUrl;
  21. /**
  22. * @var string
  23. */
  24. private $btnTxt;
  25. /**
  26. * @param string $title
  27. * @param string $url
  28. * @param string $description
  29. * @param string $picUrl
  30. * @param string $btnTxt
  31. */
  32. public function __construct(string $title, string $url, string $description = '', string $picUrl = '', string $btnTxt = '')
  33. {
  34. $this->title = $title;
  35. $this->url = $url;
  36. $this->description = $description;
  37. $this->picUrl = $picUrl;
  38. $this->btnTxt = $btnTxt;
  39. }
  40. /**
  41. * @return array
  42. */
  43. public function formatForReply(): array
  44. {
  45. return [
  46. 'Title' => $this->title,
  47. 'Description' => $this->description,
  48. 'PicUrl' => $this->picUrl,
  49. 'Url' => $this->url
  50. ];
  51. }
  52. /**
  53. * @return array
  54. */
  55. public function formatForResponse(): array
  56. {
  57. return [
  58. 'title' => $this->title,
  59. 'description' => $this->description,
  60. 'url' => $this->url,
  61. 'picurl' => $this->picUrl,
  62. 'btntxt' => $this->btnTxt
  63. ];
  64. }
  65. }