<?php

namespace Linksy\SearchAndReplace\Plugli\Standard\Helpers;

use Linksy\SearchAndReplace\Plugli\Standard\Common\Traits\Hooker;
abstract class Events
{
    use Hooker;
    public $prefix = 'plugli_';
    public $name;
    // string
    public $interval;
    // string
    function __construct($interval)
    {
        $this->interval = $interval;
        $this->action($this->get_name(), 'handler');
    }
    public function get_name()
    {
        return $this->prefix . $this->name;
    }
    public function get_interval()
    {
        return $this->interval;
    }
    abstract protected function handle();
    public function handler()
    {
        $slack_data = ['hook_name' => $this->get_name(), 'success' => \true];
        try {
            // Call the actual cron job callback and store the result
            $slack_data['summary'] = $this->handle();
        } catch (\Exception $e) {
            $slack_data['success'] = \false;
            $slack_data['reason'] = $e->getMessage();
        } finally {
            return $slack_data;
        }
    }
}
