Coverage index

src/StatisticsViewsResult.php

Lines: 100.00%

LineHitsSource
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) {
426
    $this->total = (int) $total_count;
436
    $this->today = (int) $day_count;
446
    $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() {
546
    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() {
645
    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() {
745
    return $this->timestamp;
75
  }
76
77
}