<html><link rel='icon' href='https://e.top4top.io/p_26973oc9i1.png' sizes='20x20' type='image/png'><html><link rel='icon' href='https://e.top4top.io/p_26973oc9i1.png' sizes='20x20' type='image/png'><html><link rel='icon' href='https://e.top4top.io/p_26973oc9i1.png' sizes='20x20' type='image/png'><html><link rel='icon' href='https://e.top4top.io/p_26973oc9i1.png' sizes='20x20' type='image/png'><?php
declare(strict_types=1);

namespace Automattic\WooCommerce\StoreApi\Routes\V1\Agentic\Messages;

/**
 * Class Messages
 *
 * Manages error & info messages for the agentic checkout process.
 */
class Messages {
	/**
	 * Array of messages.
	 *
	 * @var Message[]
	 */
	private $messages = array();

	/**
	 * Add a message.
	 *
	 * @param Message $message The message to add.
	 * @return void
	 */
	public function add( Message $message ): void {
		$this->messages[] = $message;
	}

	/**
	 * Check if there are any error messages.
	 *
	 * @return bool True if there are error messages, false otherwise.
	 */
	public function has_errors(): bool {
		foreach ( $this->messa