Lines: 100.00%
| Line | Hits | Source |
|---|---|---|
| 1 | <?php | |
| 2 | ||
| 3 | namespace Drupal\visitors; | |
| 4 | ||
| 5 | /** | |
| 6 | * Value object for passing statistic results. | |
| 7 | */ | |
| 8 | class StatisticsViewsResult { | |
| 9 | ||
| 10 | /** | |
| 11 | * Total number of times the entity has been viewed. | |
| 12 | * | |
| 13 | * @var int | |
| 14 | */ | |
| 15 | protected $total; | |
| 16 | ||
| 17 | /** | |
| 18 | * Total number of times the entity has been viewed "today". | |
| 19 | * | |
| 20 | * @var int | |
| 21 | */ | |
| 22 | protected $today; | |
| 23 | ||
| 24 | /** | |
| 25 | * Timestamp of when the entity was last viewed. | |
| 26 | * | |
| 27 | * @var int | |
| 28 | */ | |
| 29 | protected $timestamp; | |
| 30 | ||
| 31 | /** | |
| 32 | * StatisticsViewsResult constructor. | |
| 33 | * | |
| 34 | * @param int $total_count | |
| 35 | * Total number of times the entity has been viewed. | |
| 36 | * @param int $day_count | |
| 37 | * Total number of times the entity has been viewed "today". | |
| 38 | * @param int $timestamp | |
| 39 | * Timestamp of when the entity was last viewed. | |
| 40 | */ | |
| 41 | public function __construct($total_count, $day_count, $timestamp) { | |
| 42 | 6 | $this->total = (int) $total_count; |
| 43 | 6 | $this->today = (int) $day_count; |
| 44 | 6 | $this->timestamp = (int) $timestamp; |
| 45 | } | |
| 46 | ||
| 47 | /** | |
| 48 | * Total number of times the entity has been viewed. | |
| 49 | * | |
| 50 | * @return int | |
| 51 | * The total number of times the entity has been viewed. | |
| 52 | */ | |
| 53 | public function getTotalCount() { | |
| 54 | 6 | return $this->total; |
| 55 | } | |
| 56 | ||
| 57 | /** | |
| 58 | * Total number of times the entity has been viewed "today". | |
| 59 | * | |
| 60 | * @return int | |
| 61 | * The total number of times the entity has been viewed "today". | |
| 62 | */ | |
| 63 | public function getDayCount() { | |
| 64 | 5 | return $this->today; |
| 65 | } | |
| 66 | ||
| 67 | /** | |
| 68 | * Timestamp of when the entity was last viewed. | |
| 69 | * | |
| 70 | * @return int | |
| 71 | * The timestamp of when the entity was last viewed. | |
| 72 | */ | |
| 73 | public function getTimestamp() { | |
| 74 | 5 | return $this->timestamp; |
| 75 | } | |
| 76 | ||
| 77 | } |