*/ 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>> 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> The posts as minimal arrays. */ public function to_minimal_array(): array { $result = []; foreach ( $this->posts as $post ) { $result[] = $post->to_minimal_array(); } return $result; } }