<?php
namespace PixelioCartAbandonRecoveryMore\Includes\Mocks;
if (!defined('ABSPATH')) exit;
class Pixelio_Cart_Abandon_Recovery_More_WC_Coupon
{
	private $coupons = [];
	public $code;
	public $discount_type;
	public $amount;
	public $usage_limit;
	public $individual_use;
	public $email_restrictions;
	public $expires;
	private static $next_id = 1;

	public $id;
	public function set_code($code)
	{
		$this->code = $code;
	}

	public function set_discount_type($type)
	{
		$this->discount_type = $type;
	}

	public function set_amount($amount)
	{
		$this->amount = $amount;
	}

	public function set_usage_limit($limit)
	{
		$this->usage_limit = $limit;
	}

	public function set_individual_use($bool)
	{
		$this->individual_use = $bool;
	}

	public function set_email_restrictions($emails)
	{
		$this->email_restrictions = $emails;
	}

	public function set_date_expires($date)
	{
		$this->expires = $date;
	}
	public function pixelio_create_coupon(array $data): int
	{
		$id = count($this->coupons) + 1;

		$this->coupons[$id] = [
			'id' => $id,
			'code' => $data['code'] ?? '',
			'amount' => $data['amount'] ?? 0,
			'discount_type' => $data['discount_type'] ?? 'fixed_cart',
			'usage_limit' => $data['usage_limit'] ?? null,
			'expiry_date' => $data['expiry_date'] ?? null,
		];

		return $id;
	}

	public function save()
	{
		if (!$this->id) {
			$this->id = self::$next_id++;
		}

		return $this->id;
	}
}
