<?php

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

abstract class AIEO_Push_Trigger_Base {

    
    abstract public function get_id();

    
    abstract public function get_label();

    
    public function dedup_days() { return 7; }

    
    public function cap_per_day()  { return 1; }
    public function cap_per_week() { return 4; }

    
    public function respects_quiet_hours() { return true; }

    
    abstract public function produce_candidates($limit = 200);

    
    public function register_hooks() {}
}

class AIEO_Push_Trigger_Registry {

    
    private static $instance = null;

    
    private $triggers = array();

    public static function instance() {
        if (self::$instance === null) {
            self::$instance = new self();
        }
        return self::$instance;
    }

    private function __construct() {}

    public function register(AIEO_Push_Trigger_Base $trigger) {
        $id = (string) $trigger->get_id();
        if ($id === '') { return; }
        if (isset($this->triggers[$id])) { return; } 
        $this->triggers[$id] = $trigger;
        $trigger->register_hooks();
    }

    
    public function get($id) {
        return isset($this->triggers[$id]) ? $this->triggers[$id] : null;
    }

    
    public function all() {
        return $this->triggers;
    }
}
