PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 28.6
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v28.6
28.6 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 All 130 releases
wordpress-seo / src / dashboard / domain / search-rankings / search-ranking-data.php

search-ranking-data.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 28.6, at src/dashboard/domain/search-rankings/search-ranking-data.php

125 lines 2.4 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\Search_Rankings;
5
6 use Yoast\WP\SEO\Dashboard\Domain\Data_Provider\Data_Interface;
7
8 /**
9 * Domain object that represents a single Search Ranking Data record.
10 */
11 class Search_Ranking_Data implements Data_Interface {
12
13 /**
14 * The amount of clicks a `subject` gets.
15 *
16 * @var int
17 */
18 private $clicks;
19
20 /**
21 * The click-through rate a `subject` gets.
22 *
23 * @var float
24 */
25 private $ctr;
26
27 /**
28 * The amount of impressions a `subject` gets.
29 *
30 * @var int
31 */
32 private $impressions;
33
34 /**
35 * The average position for the given `subject`.
36 *
37 * @var float
38 */
39 private $position;
40
41 /**
42 * In the context of this domain object subject can represent a `URI` or a `search term`
43 *
44 * @var string
45 */
46 private $subject;
47
48 /**
49 * The constructor.
50 *
51 * @param int $clicks The clicks.
52 * @param float $ctr The ctr.
53 * @param int $impressions The impressions.
54 * @param float $position The position.
55 * @param string $subject The subject of the data.
56 */
57 public function __construct( int $clicks, float $ctr, int $impressions, float $position, string $subject ) {
58 $this->clicks = $clicks;
59 $this->ctr = $ctr;
60 $this->impressions = $impressions;
61 $this->position = $position;
62 $this->subject = $subject;
63 }
64
65 /**
66 * The array representation of this domain object.
67 *
68 * @return array<string|float|int|string[]>
69 */
70 public function to_array(): array {
71 return [
72 'clicks' => $this->clicks,
73 'ctr' => $this->ctr,
74 'impressions' => $this->impressions,
75 'position' => $this->position,
76 'subject' => $this->subject,
77 ];
78 }
79
80 /**
81 * Gets the clicks.
82 *
83 * @return string The clicks.
84 */
85 public function get_clicks(): string {
86 return $this->clicks;
87 }
88
89 /**
90 * Gets the click-through rate.
91 *
92 * @return string The click-through rate.
93 */
94 public function get_ctr(): string {
95 return $this->ctr;
96 }
97
98 /**
99 * Gets the impressions.
100 *
101 * @return string The impressions.
102 */
103 public function get_impressions(): string {
104 return $this->impressions;
105 }
106
107 /**
108 * Gets the position.
109 *
110 * @return string The position.
111 */
112 public function get_position(): string {
113 return $this->position;
114 }
115
116 /**
117 * Gets the subject.
118 *
119 * @return string The subject.
120 */
121 public function get_subject(): string {
122 return $this->subject;
123 }
124 }
125