<?php
namespace PixelioCartAbandonRecoveryMore\Includes\Validators;

if (!defined('ABSPATH')) exit;

class Pixelio_Cart_Abandon_Recovery_More_Wishlist_Email_Validator{
	public function __construct()
	{
	}

	private const DISPOSABLE = [
		'mailinator.com', 'guerrillamail.com', 'tempmail.com',
		'throwam.com', 'yopmail.com', 'trashmail.com',
		'sharklasers.com', 'dispostable.com',
	];


	public function validate( string $email ): bool {

		// 1. Format de base via WordPress
		if ( ! is_email( $email ) ) return false;

		// 2. Domaine jetable
		$domain = strtolower( substr( $email, strpos( $email, '@' ) + 1 ) );
		if ( in_array( $domain, self::DISPOSABLE, true ) ) return false;

		// 3. Hook pour laisser le marchand étendre la liste
		$extra = apply_filters( 'wishlist_disposable_domains', [] );
		if ( in_array( $domain, $extra, true ) ) return false;

		return true;
	}

}
