<?php

namespace AC\Promo;

use AC\Promo;
use AC\Type\DateRange;
use AC\Type\Url;
use AC\Type\Url\CouponCode;

class BlackFriday extends Promo
{

    /**
     * @var string
     */
    private $coupon_code;

    public function __construct(DateRange $date_range, $coupon_code = null)
    {
        parent::__construct(
            'black-friday',
            40,
            $date_range
        );

        $this->coupon_code = $coupon_code;
    }

    public function get_title(): string
    {
        return sprintf(
            __('Save up to %s from Black Friday to Cyber Monday', 'codepress-admin-columns'),
            $this->discount . '%'
        );
    }

    public function get_message(): string
    {
        $message = sprintf(__('Get %s now', 'codepress-admin-columns'), '<strong>Admin Columns Pro</strong>');
        $message = sprintf(
            '%s! <a target="_blank" href="%s">%s</a>',
            $this->get_title(),
            $this->get_url()->get_url(),
            $message
        );

        return $message;
    }

    public function get_url(): Url
    {
        return $this->coupon_code
            ? new CouponCode(parent::get_url(), $this->coupon_code)
            : parent::get_url();
    }

}