PluginProbe ʕ •ᴥ•ʔ
Independent Analytics – WordPress Analytics Plugin / 2.7.2
Independent Analytics – WordPress Analytics Plugin v2.7.2
2.15.5 2.15.4 2.15.3 2.15.2 2.15.1 2.15.0 2.14.10 trunk 1.1 1.10 1.10.1 1.11 1.12 1.13 1.14 1.15 1.16 1.17 1.17.1 1.17.2 1.17.3 1.17.4 1.18 1.18.1 1.19.0 1.19.1 1.2 1.20.0 1.21.0 1.22.0 1.22.1 1.23.0 1.23.1 1.24.0 1.24.1 1.25.0 1.25.1 1.26.0 1.27.0 1.28.0 1.28.1 1.28.2 1.28.3 1.29.0 1.3 1.30.0 1.30.1 1.4 1.5 1.6 1.7 1.8 1.9 2.0.0 2.0.1 2.1.4 2.1.5 2.1.6 2.10.0 2.10.1 2.10.2 2.10.3 2.10.4 2.11.0 2.11.1 2.11.10 2.11.2 2.11.3 2.11.4 2.11.5 2.11.6 2.11.7 2.11.8 2.11.9 2.12.0 2.12.1 2.12.2 2.13.1 2.13.2 2.13.5 2.13.6 2.14.0 2.14.1 2.14.2 2.14.4 2.14.6 2.14.7 2.14.8 2.14.9 2.2.0 2.2.1 2.3.1 2.3.2 2.4.2 2.4.3 2.5.0 2.5.1 2.6.0 2.6.1 2.6.2 2.6.3 2.6.4 2.7.0 2.7.1 2.7.2 2.7.3 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.8 2.8.9 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7
independent-analytics / IAWP / Models / Universal_Model_Columns.php
independent-analytics / IAWP / Models Last commit date
Campaign.php 2 years ago Current_Traffic.php 2 years ago Device.php 2 years ago Geo.php 2 years ago Page.php 2 years ago Page_Author_Archive.php 2 years ago Page_Date_Archive.php 2 years ago Page_Home.php 2 years ago Page_Not_Found.php 2 years ago Page_Post_Type_Archive.php 2 years ago Page_Search.php 2 years ago Page_Singular.php 2 years ago Page_Term_Archive.php 2 years ago Page_Virtual.php 2 years ago Referrer.php 2 years ago Universal_Model_Columns.php 2 years ago Visitor.php 2 years ago WooCommerce_Stats.php 2 years ago
Universal_Model_Columns.php
159 lines
1 <?php
2
3 namespace IAWP\Models;
4
5 use IAWPSCOPED\Illuminate\Support\Str;
6 /** @internal */
7 trait Universal_Model_Columns
8 {
9 /**
10 * Handle dynamic column names such as those for form tracking
11 */
12 public function __call($name, $arguments)
13 {
14 if (Str::startsWith($name, 'form_submissions_for_')) {
15 return $this->as_int($name);
16 } elseif (Str::startsWith($name, 'form_conversion_rate_for_')) {
17 return $this->as_float($name);
18 }
19 }
20 public function form_submissions() : int
21 {
22 return $this->as_int('form_submissions');
23 }
24 public function form_conversion_rate() : float
25 {
26 return $this->as_float('form_conversion_rate');
27 }
28 public function wc_orders() : float
29 {
30 return $this->as_float('wc_orders');
31 }
32 public function wc_gross_sales() : float
33 {
34 return $this->as_float('wc_gross_sales');
35 }
36 public function wc_refunds() : float
37 {
38 return $this->as_float('wc_refunds');
39 }
40 public function wc_refunded_amount() : float
41 {
42 return $this->as_float('wc_refunded_amount');
43 }
44 public function wc_net_sales() : float
45 {
46 return $this->as_float('wc_net_sales');
47 }
48 public function wc_conversion_rate() : float
49 {
50 return $this->as_float('wc_conversion_rate');
51 }
52 public function wc_earnings_per_visitor() : float
53 {
54 return $this->as_float('wc_earnings_per_visitor');
55 }
56 public function wc_average_order_volume() : float
57 {
58 return $this->as_float('wc_average_order_volume');
59 }
60 public function views() : int
61 {
62 return $this->as_int('views');
63 }
64 public function previous_period_views() : int
65 {
66 return $this->as_int('previous_period_views');
67 }
68 public function views_growth() : float
69 {
70 return $this->as_float('views_growth');
71 }
72 public function views_per_session() : float
73 {
74 return $this->as_float('views_per_session');
75 }
76 public function visitors() : int
77 {
78 return $this->as_int('visitors');
79 }
80 public function previous_period_visitors() : int
81 {
82 return $this->as_int('previous_period_views');
83 }
84 public function visitors_growth() : float
85 {
86 return $this->as_float('visitors_growth');
87 }
88 public function average_session_duration() : ?int
89 {
90 return $this->as_int('average_session_duration', null);
91 }
92 public function average_session_duration_growth() : float
93 {
94 $current = $this->average_session_duration();
95 $previous = $this->previous_period_average_session_duration();
96 if ($current == 0 || $previous == 0) {
97 return 0;
98 } else {
99 return ($current - $previous) / $previous * 100;
100 }
101 }
102 public function average_view_duration() : ?int
103 {
104 return $this->as_int('average_view_duration', null);
105 }
106 public function average_view_duration_growth() : float
107 {
108 $current = $this->average_view_duration();
109 $previous = $this->previous_period_average_view_duration();
110 if ($current == 0 || $previous == 0) {
111 return 0;
112 } else {
113 return ($current - $previous) / $previous * 100;
114 }
115 }
116 public function sessions() : int
117 {
118 return $this->as_int('sessions');
119 }
120 public function previous_period_sessions() : int
121 {
122 return $this->as_int('previous_period_sessions');
123 }
124 public function sessions_growth() : float
125 {
126 $current = $this->sessions();
127 $previous = $this->previous_period_sessions();
128 if ($current == 0 || $previous == 0) {
129 return 0;
130 } else {
131 return ($current - $previous) / $previous * 100;
132 }
133 }
134 public function previous_period_average_session_duration() : int
135 {
136 return $this->as_int('previous_period_average_session_duration');
137 }
138 public function previous_period_average_view_duration() : int
139 {
140 return $this->as_int('previous_period_average_view_duration');
141 }
142 public function bounces() : int
143 {
144 return $this->as_int('bounces');
145 }
146 public function bounce_rate() : float
147 {
148 return $this->as_float('bounce_rate');
149 }
150 private function as_float($property, $default = 0) : ?float
151 {
152 return \property_exists($this->row, $property) && $this->row->{$property} !== null ? \floatval($this->row->{$property}) : $default;
153 }
154 private function as_int($property, $default = 0) : ?int
155 {
156 return \property_exists($this->row, $property) && $this->row->{$property} !== null ? \intval($this->row->{$property}) : $default;
157 }
158 }
159