PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 27.8
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v27.8
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
wordpress-seo / src / dashboard / infrastructure / analytics-4 / analytics-4-parameters.php

analytics-4-parameters.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 27.8, at src/dashboard/infrastructure/analytics-4/analytics-4-parameters.php

140 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong -- Needed in the folder structure.
4 namespace Yoast\WP\SEO\Dashboard\Infrastructure\Analytics_4;
5
6 use Yoast\WP\SEO\Dashboard\Domain\Data_Provider\Parameters;
7
8 /**
9 * Domain object to add Analytics 4 specific data to the parameters.
10 */
11 class Analytics_4_Parameters extends Parameters {
12
13 /**
14 * The dimensions to query.
15 *
16 * @var array<array<string, string>> $dimensions
17 */
18 private $dimensions = [];
19
20 /**
21 * The dimensions filters.
22 *
23 * @var array<string, array<string>> $dimension_filters
24 */
25 private $dimension_filters = [];
26
27 /**
28 * The metrics.
29 *
30 * @var array<array<string, string>> $metrics
31 */
32 private $metrics = [];
33
34 /**
35 * The order by.
36 *
37 * @var array<array<string, array<string, string>>> $order_by
38 */
39 private $order_by = [];
40
41 /**
42 * Sets the dimensions.
43 *
44 * @link https://developers.google.com/analytics/devguides/reporting/data/v1/rest/v1beta/Dimension
45 *
46 * @param array<string> $dimensions The dimensions.
47 *
48 * @return void
49 */
50 public function set_dimensions( array $dimensions ): void {
51 foreach ( $dimensions as $dimension ) {
52 $this->dimensions[] = [ 'name' => $dimension ];
53 }
54 }
55
56 /**
57 * Getter for the dimensions.
58 *
59 * @return array<array<string, string>>
60 */
61 public function get_dimensions(): array {
62 return $this->dimensions;
63 }
64
65 /**
66 * Sets the dimension filters.
67 *
68 * @param array<string, array<string>> $dimension_filters The dimension filters.
69 *
70 * @return void
71 */
72 public function set_dimension_filters( array $dimension_filters ): void {
73 $this->dimension_filters = $dimension_filters;
74 }
75
76 /**
77 * Getter for the dimension filters.
78 *
79 * @return array<string, array<string>>
80 */
81 public function get_dimension_filters(): array {
82 return $this->dimension_filters;
83 }
84
85 /**
86 * Sets the metrics.
87 *
88 * @link https://developers.google.com/analytics/devguides/reporting/data/v1/rest/v1beta/Metric
89 *
90 * @param array<string> $metrics The metrics.
91 *
92 * @return void
93 */
94 public function set_metrics( array $metrics ): void {
95 foreach ( $metrics as $metric ) {
96 $this->metrics[] = [ 'name' => $metric ];
97 }
98 }
99
100 /**
101 * Getter for the metrics.
102 *
103 * @return array<array<string, string>>
104 */
105 public function get_metrics(): array {
106 return $this->metrics;
107 }
108
109 /**
110 * Sets the order by.
111 *
112 * @link https://developers.google.com/analytics/devguides/reporting/data/v1/rest/v1beta/OrderBy
113 *
114 * @param string $key The key to order by.
115 * @param string $name The name to order by.
116 *
117 * @return void
118 */
119 public function set_order_by( string $key, string $name ): void {
120 $order_by = [
121 [
122 $key => [
123 $key . 'Name' => $name,
124 ],
125 ],
126 ];
127
128 $this->order_by = $order_by;
129 }
130
131 /**
132 * Getter for the order by.
133 *
134 * @return array<array<string, array<string, string>>>
135 */
136 public function get_order_by(): array {
137 return $this->order_by;
138 }
139 }
140