<?php

namespace KupShop\KupShopBundle\Event;

use Symfony\Contracts\EventDispatcher\Event;

/**
 * The kupshop.cron_run event is dispatched each time cron is run.
 *
 * expensive = true marks event repeated once per day
 * expensive = false marks event repeated every two hours
 */
class CronEvent extends Event
{
    /** Every 10 minutes */
    public const RUN_FREQUENT = 'kupshop.cron_run_frequent';

    /** Every 2 hours */
    public const RUN_NORMAL = 'kupshop.cron_run_normal';

    /** Every night */
    public const RUN_EXPENSIVE = 'kupshop.cron_run_expensive';

    /**
     * @var string
     */
    protected $type;

    /**
     * @var float
     */
    protected $startTime;

    public function __construct(string $type)
    {
        $this->type = $type;
        $this->startTime = getScriptTime();
    }

    /**
     * @return string
     */
    public function getType()
    {
        return $this->type;
    }

    public function getStartTime(): float
    {
        return $this->startTime;
    }
}
