Нема описа

NewsletterStatistics.php 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. namespace MailPoet\Newsletter\Statistics;
  3. if (!defined('ABSPATH')) exit;
  4. class NewsletterStatistics {
  5. /** @var int */
  6. private $clickCount;
  7. /** @var int */
  8. private $openCount;
  9. /** @var int */
  10. private $machineOpenCount;
  11. /** @var int */
  12. private $unsubscribeCount;
  13. /** @var int */
  14. private $bounceCount;
  15. /** @var int */
  16. private $totalSentCount;
  17. /** @var WooCommerceRevenue|null */
  18. private $wooCommerceRevenue;
  19. public function __construct(
  20. $clickCount,
  21. $openCount,
  22. $unsubscribeCount,
  23. $bounceCount,
  24. $totalSentCount,
  25. $wooCommerceRevenue
  26. ) {
  27. $this->clickCount = $clickCount;
  28. $this->openCount = $openCount;
  29. $this->unsubscribeCount = $unsubscribeCount;
  30. $this->bounceCount = $bounceCount;
  31. $this->totalSentCount = $totalSentCount;
  32. $this->wooCommerceRevenue = $wooCommerceRevenue;
  33. }
  34. public function getClickCount(): int {
  35. return $this->clickCount;
  36. }
  37. public function getOpenCount(): int {
  38. return $this->openCount;
  39. }
  40. public function getUnsubscribeCount(): int {
  41. return $this->unsubscribeCount;
  42. }
  43. public function getBounceCount(): int {
  44. return $this->unsubscribeCount;
  45. }
  46. public function getTotalSentCount(): int {
  47. return $this->totalSentCount;
  48. }
  49. public function getWooCommerceRevenue(): ?WooCommerceRevenue {
  50. return $this->wooCommerceRevenue;
  51. }
  52. public function setMachineOpenCount(int $machineOpenCount): void {
  53. $this->machineOpenCount = $machineOpenCount;
  54. }
  55. public function getMachineOpenCount(): int {
  56. return $this->machineOpenCount;
  57. }
  58. public function asArray(): array {
  59. return [
  60. 'clicked' => $this->clickCount,
  61. 'opened' => $this->openCount,
  62. 'machineOpened' => $this->machineOpenCount,
  63. 'unsubscribed' => $this->unsubscribeCount,
  64. 'bounced' => $this->bounceCount,
  65. 'revenue' => empty($this->wooCommerceRevenue) ? null : $this->wooCommerceRevenue->asArray(),
  66. ];
  67. }
  68. }