wordpress-seo
/
src
/
llms-txt
/
domain
/
available-posts
/
data-provider
/
available-posts-data.php
available-posts-data.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI trunk, at src/llms-txt/domain/available-posts/data-provider/available-posts-data.php
| 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 | use Yoast\WP\SEO\Llms_Txt\Domain\Content_Types\Content_Type_Entry; |
| 8 | |
| 9 | /** |
| 10 | * Domain object that represents a Available Posts data record. |
| 11 | */ |
| 12 | class Available_Posts_Data implements Data_Interface { |
| 13 | |
| 14 | /** |
| 15 | * The content type entry. |
| 16 | * |
| 17 | * @var Content_Type_Entry |
| 18 | */ |
| 19 | private $content_type_entry; |
| 20 | |
| 21 | /** |
| 22 | * The constructor. |
| 23 | * |
| 24 | * @param Content_Type_Entry $content_type_entry The content type entry. |
| 25 | */ |
| 26 | public function __construct( Content_Type_Entry $content_type_entry ) { |
| 27 | $this->content_type_entry = $content_type_entry; |
| 28 | } |
| 29 | |
| 30 | /** |
| 31 | * The array representation of this domain object. |
| 32 | * |
| 33 | * @return array<string|float|int|string[]> |
| 34 | */ |
| 35 | public function to_array(): array { |
| 36 | return [ |
| 37 | 'id' => $this->content_type_entry->get_id(), |
| 38 | 'title' => $this->content_type_entry->get_title(), |
| 39 | 'slug' => $this->content_type_entry->get_slug(), |
| 40 | ]; |
| 41 | } |
| 42 | } |
| 43 |