HEX
Server: Apache
System: Linux webd001.cluster127.gra.hosting.ovh.net 6.18.42-ovh-vps-grsec-zfs+ #1 SMP PREEMPT_DYNAMIC Wed Aug 5 15:59:48 CEST 2026 x86_64
User: mciraet (192513)
PHP: 8.2.31
Disabled: _dyuweyrj4,_dyuweyrj4r,dl
Upload Files
File: /home/mciraet/www/wp-content/plugins/wordpress-seo/src/ai/content-planner/domain/post-list.php
<?php
// phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong -- Needed in the folder structure.
namespace Yoast\WP\SEO\AI\Content_Planner\Domain;

/**
 * List of posts.
 */
class Post_List {

	/**
	 * The posts.
	 *
	 * @var array<Post>
	 */
	private $posts = [];

	/**
	 * Adds a post to the list.
	 *
	 * @param Post $post A post.
	 *
	 * @return void
	 */
	public function add( Post $post ): void {
		$this->posts[] = $post;
	}

	/**
	 * Returns this object in array format.
	 *
	 * @return array<array<string, string|bool|array<string, int>>> The posts as an array.
	 */
	public function to_array(): array {
		$result = [];
		foreach ( $this->posts as $post ) {
			$result[] = $post->to_array();
		}

		return $result;
	}

	/**
	 * Returns the minimal array representation suitable for the REST response.
	 *
	 * @return array<array<string, string>> The posts as minimal arrays.
	 */
	public function to_minimal_array(): array {
		$result = [];
		foreach ( $this->posts as $post ) {
			$result[] = $post->to_minimal_array();
		}

		return $result;
	}
}