Intervals
2 years ago
Campaign_Statistics.php
2 years ago
City_Statistics.php
2 years ago
Country_Statistics.php
2 years ago
Device_Browser_Statistics.php
2 years ago
Device_OS_Statistics.php
2 years ago
Device_Type_Statistics.php
2 years ago
Page_Statistics.php
2 years ago
Referrer_Statistics.php
2 years ago
Statistic.php
2 years ago
Statistics.php
2 years ago
Statistic.php
36 lines
| 1 | <?php |
| 2 | |
| 3 | namespace IAWP\Statistics; |
| 4 | |
| 5 | /** @internal */ |
| 6 | class Statistic |
| 7 | { |
| 8 | private $value; |
| 9 | private $previous_value; |
| 10 | private $daily_summary; |
| 11 | public function __construct($value = 0, $previous_value = 0, $daily_summary = []) |
| 12 | { |
| 13 | $this->value = $value; |
| 14 | $this->previous_value = $previous_value; |
| 15 | $this->daily_summary = $daily_summary; |
| 16 | } |
| 17 | public function value() |
| 18 | { |
| 19 | return $this->value; |
| 20 | } |
| 21 | public function growth() |
| 22 | { |
| 23 | if ($this->value == 0 && $this->previous_value != 0) { |
| 24 | return -100; |
| 25 | } elseif ($this->value == 0 || $this->previous_value == 0) { |
| 26 | return 0; |
| 27 | } |
| 28 | $percent_growth = ($this->value / $this->previous_value - 1) * 100; |
| 29 | return \round($percent_growth, 0); |
| 30 | } |
| 31 | public function daily_summary() |
| 32 | { |
| 33 | return $this->daily_summary; |
| 34 | } |
| 35 | } |
| 36 |