PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 28.2
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v28.2
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 / domain / traffic / comparison-traffic-data.php

comparison-traffic-data.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 28.2, at src/dashboard/domain/traffic/comparison-traffic-data.php

75 lines 1.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\Domain\Traffic;
5
6 use Yoast\WP\SEO\Dashboard\Domain\Data_Provider\Data_Interface;
7
8 /**
9 * Domain object that represents a single Comparison Traffic record.
10 */
11 class Comparison_Traffic_Data implements Data_Interface {
12
13 public const CURRENT_PERIOD_KEY = 'current';
14 public const PREVIOUS_PERIOD_KEY = 'previous';
15
16 /**
17 * The current traffic data.
18 *
19 * @var Traffic_Data
20 */
21 private $current_traffic_data;
22
23 /**
24 * The previous traffic data.
25 *
26 * @var Traffic_Data
27 */
28 private $previous_traffic_data;
29
30 /**
31 * The constructor.
32 *
33 * @param Traffic_Data $current_traffic_data The current traffic data.
34 * @param Traffic_Data $previous_traffic_data The previous traffic data.
35 */
36 public function __construct( ?Traffic_Data $current_traffic_data = null, ?Traffic_Data $previous_traffic_data = null ) {
37 $this->current_traffic_data = $current_traffic_data;
38 $this->previous_traffic_data = $previous_traffic_data;
39 }
40
41 /**
42 * Sets the current traffic data.
43 *
44 * @param Traffic_Data $current_traffic_data The current traffic data.
45 *
46 * @return void
47 */
48 public function set_current_traffic_data( Traffic_Data $current_traffic_data ): void {
49 $this->current_traffic_data = $current_traffic_data;
50 }
51
52 /**
53 * Sets the previous traffic data.
54 *
55 * @param Traffic_Data $previous_traffic_data The previous traffic data.
56 *
57 * @return void
58 */
59 public function set_previous_traffic_data( Traffic_Data $previous_traffic_data ): void {
60 $this->previous_traffic_data = $previous_traffic_data;
61 }
62
63 /**
64 * The array representation of this domain object.
65 *
66 * @return array<string|float|int|string[]>
67 */
68 public function to_array(): array {
69 return [
70 'current' => $this->current_traffic_data->to_array(),
71 'previous' => $this->previous_traffic_data->to_array(),
72 ];
73 }
74 }
75