Automation.php
2 months ago
AutomationRun.php
1 year ago
AutomationRunLog.php
1 year ago
AutomationStatistics.php
9 months ago
AutomationTemplate.php
6 months ago
AutomationTemplateCategory.php
2 years ago
Field.php
2 years ago
Filter.php
3 years ago
FilterGroup.php
2 months ago
Filters.php
2 months ago
NextStep.php
2 years ago
Step.php
2 months ago
StepRunArgs.php
2 years ago
StepValidationArgs.php
3 years ago
Subject.php
3 years ago
SubjectEntry.php
3 years ago
index.php
3 years ago
AutomationStatistics.php
103 lines
| 1 | <?php declare(strict_types = 1); |
| 2 | |
| 3 | namespace MailPoet\Automation\Engine\Data; |
| 4 | |
| 5 | if (!defined('ABSPATH')) exit; |
| 6 | |
| 7 | |
| 8 | class AutomationStatistics { |
| 9 | |
| 10 | private $automationId; |
| 11 | private $versionId; |
| 12 | private $entered; |
| 13 | private $inProgress; |
| 14 | private $emailsSent; |
| 15 | private $emailsOpened; |
| 16 | private $emailsClicked; |
| 17 | private $orders; |
| 18 | private $revenue; |
| 19 | |
| 20 | public function __construct( |
| 21 | int $automationId, |
| 22 | int $entered = 0, |
| 23 | int $inProcess = 0, |
| 24 | ?int $versionId = null, |
| 25 | int $emailsSent = 0, |
| 26 | int $emailsOpened = 0, |
| 27 | int $emailsClicked = 0, |
| 28 | int $orders = 0, |
| 29 | float $revenue = 0.0 |
| 30 | ) { |
| 31 | $this->automationId = $automationId; |
| 32 | $this->entered = $entered; |
| 33 | $this->inProgress = $inProcess; |
| 34 | $this->versionId = $versionId; |
| 35 | $this->emailsSent = $emailsSent; |
| 36 | $this->emailsOpened = $emailsOpened; |
| 37 | $this->emailsClicked = $emailsClicked; |
| 38 | $this->orders = $orders; |
| 39 | $this->revenue = $revenue; |
| 40 | } |
| 41 | |
| 42 | public function getAutomationId(): int { |
| 43 | return $this->automationId; |
| 44 | } |
| 45 | |
| 46 | public function getVersionId(): ?int { |
| 47 | return $this->versionId; |
| 48 | } |
| 49 | |
| 50 | public function getEntered(): int { |
| 51 | return $this->entered; |
| 52 | } |
| 53 | |
| 54 | public function getInProgress(): int { |
| 55 | return $this->inProgress; |
| 56 | } |
| 57 | |
| 58 | public function getExited(): int { |
| 59 | return $this->getEntered() - $this->getInProgress(); |
| 60 | } |
| 61 | |
| 62 | public function getEmailsSent(): int { |
| 63 | return $this->emailsSent; |
| 64 | } |
| 65 | |
| 66 | public function getEmailsOpened(): int { |
| 67 | return $this->emailsOpened; |
| 68 | } |
| 69 | |
| 70 | public function getEmailsClicked(): int { |
| 71 | return $this->emailsClicked; |
| 72 | } |
| 73 | |
| 74 | public function getOrders(): int { |
| 75 | return $this->orders; |
| 76 | } |
| 77 | |
| 78 | public function getRevenue(): float { |
| 79 | return $this->revenue; |
| 80 | } |
| 81 | |
| 82 | public function toArray(): array { |
| 83 | return [ |
| 84 | 'automation_id' => $this->getAutomationId(), |
| 85 | 'totals' => [ |
| 86 | 'entered' => $this->getEntered(), |
| 87 | 'in_progress' => $this->getInProgress(), |
| 88 | 'exited' => $this->getExited(), |
| 89 | ], |
| 90 | 'emails' => [ |
| 91 | 'sent' => $this->getEmailsSent(), |
| 92 | 'opened' => $this->getEmailsOpened(), |
| 93 | 'clicked' => $this->getEmailsClicked(), |
| 94 | 'revenue' => [ |
| 95 | 'currency' => function_exists('get_woocommerce_currency') ? get_woocommerce_currency() : '', |
| 96 | 'value' => $this->getRevenue(), |
| 97 | 'count' => $this->getOrders(), |
| 98 | ], |
| 99 | ], |
| 100 | ]; |
| 101 | } |
| 102 | } |
| 103 |