<?php
/**
 * Status Trait.
 *
 * @package EDD\Pro\CartRecovery\Traits
 * @copyright Copyright (c) 2026, Sandhills Development, LLC
 * @license https://opensource.org/licenses/gpl-2.0.php GNU Public License
 * @since 3.6.5
 */

namespace EDD\Pro\CartRecovery\Traits;

trait Status {

	/**
	 * Returns an array of statuses to be used in the status dropdown.
	 *
	 * @since 3.6.5
	 * @return array
	 */
	protected static function get_cart_statuses(): array {
		return array(
			'tracking'     => __( 'Tracking', 'easy-digital-downloads' ),
			'abandoned'    => __( 'Abandoned', 'easy-digital-downloads' ),
			'recovered'    => __( 'Recovered', 'easy-digital-downloads' ),
			'expired'      => __( 'Expired', 'easy-digital-downloads' ),
			'unsubscribed' => __( 'Unsubscribed', 'easy-digital-downloads' ),
		);
	}

	/**
	 * Gets the statuses for emails.
	 *
	 * @since 3.6.5
	 * @return array
	 */
	protected static function get_email_statuses(): array {
		return array(
			'sent'         => __( 'Sent', 'easy-digital-downloads' ),
			'delivered'    => __( 'Delivered', 'easy-digital-downloads' ),
			'pending'      => __( 'Pending', 'easy-digital-downloads' ),
			'converted'    => __( 'Converted', 'easy-digital-downloads' ),
			'clicked'      => __( 'Clicked', 'easy-digital-downloads' ),
			'opened'       => __( 'Opened', 'easy-digital-downloads' ),
			'failed'       => __( 'Failed', 'easy-digital-downloads' ),
			'bounced'      => __( 'Bounced', 'easy-digital-downloads' ),
			'unsubscribed' => __( 'Unsubscribed', 'easy-digital-downloads' ),
		);
	}

	/**
	 * Get the label for a status.
	 *
	 * @since 3.6.5
	 * @param string $status Status value.
	 * @param string $type   Type of status (cart or email).
	 * @return string
	 */
	protected function get_status_label( $status, $type = 'cart' ): string {
		if ( 'email' === $type ) {
			return self::get_email_statuses()[ $status ] ?? $status;
		}

		return self::get_cart_statuses()[ $status ] ?? $status;
	}
}
