PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / trunk
Yoast SEO – Advanced SEO with real-time guidance and built-in AI vtrunk
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 / editors / domain / seo / keyphrase.php

keyphrase.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI trunk, at src/editors/domain/seo/keyphrase.php

60 lines 1.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
4 namespace Yoast\WP\SEO\Editors\Domain\Seo;
5
6 /**
7 * This class describes the keyphrase SEO data.
8 */
9 class Keyphrase implements Seo_Plugin_Data_Interface {
10
11 /**
12 * The keyphrase and the associated posts that use it.
13 *
14 * @var array<string>
15 */
16 private $keyphrase_usage_count;
17
18 /**
19 * The post types for the given post IDs.
20 *
21 * @var array<string>
22 */
23 private $keyphrase_usage_per_type;
24
25 /**
26 * The constructor.
27 *
28 * @param array<string> $keyphrase_usage_count The keyphrase and the associated posts that use it.
29 * @param array<string> $keyphrase_usage_per_type The post types for the given post IDs.
30 */
31 public function __construct( array $keyphrase_usage_count, array $keyphrase_usage_per_type ) {
32 $this->keyphrase_usage_count = $keyphrase_usage_count;
33 $this->keyphrase_usage_per_type = $keyphrase_usage_per_type;
34 }
35
36 /**
37 * Returns the data as an array format.
38 *
39 * @return array<string>
40 */
41 public function to_array(): array {
42 return [
43 'keyphrase_usage' => $this->keyphrase_usage_count,
44 'keyphrase_usage_per_type' => $this->keyphrase_usage_per_type,
45 ];
46 }
47
48 /**
49 * Returns the data as an array format meant for legacy use.
50 *
51 * @return array<string>
52 */
53 public function to_legacy_array(): array {
54 return [
55 'keyword_usage' => $this->keyphrase_usage_count,
56 'keyword_usage_post_types' => $this->keyphrase_usage_per_type,
57 ];
58 }
59 }
60