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 / llms-txt / domain / available-posts / data-provider / data-container.php

data-container.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI trunk, at src/llms-txt/domain/available-posts/data-provider/data-container.php

60 lines 1.2 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 // phpcs:disable Yoast.NamingConventions.NamespaceName.MaxExceeded -- Needed in the folder structure.
5 namespace Yoast\WP\SEO\Llms_Txt\Domain\Available_Posts\Data_Provider;
6
7 /**
8 * The data container.
9 */
10 class Data_Container {
11
12 /**
13 * All the data points.
14 *
15 * @var array<Data_Interface>
16 */
17 private $data_container;
18
19 /**
20 * The constructor
21 */
22 public function __construct() {
23 $this->data_container = [];
24 }
25
26 /**
27 * Method to add data.
28 *
29 * @param Data_Interface $data The data.
30 *
31 * @return void
32 */
33 public function add_data( Data_Interface $data ) {
34 $this->data_container[] = $data;
35 }
36
37 /**
38 * Method to get all the data points.
39 *
40 * @return Data_Interface[] All the data points.
41 */
42 public function get_data(): array {
43 return $this->data_container;
44 }
45
46 /**
47 * Converts the data points into an array.
48 *
49 * @return array<string, string> The array of the data points.
50 */
51 public function to_array(): array {
52 $result = [];
53 foreach ( $this->data_container as $data ) {
54 $result[] = $data->to_array();
55 }
56
57 return $result;
58 }
59 }
60