<?php
/**
 * Typed wrapper around plugin options.
 *
 * Schedule data moved to its own option (`backreload_schedules`) handled by
 * Scheduler, so this class is now just the general settings shim.
 *
 * @package Backreload\Core
 */

namespace Backreload\Core;

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

final class Options {

	const SETTINGS_KEY = 'backreload_settings';

	/** @return array<string,mixed> */
	public function settings(): array {
		return (array) get_option( self::SETTINGS_KEY, [] );
	}

	public function update_settings( array $values ): void {
		update_option( self::SETTINGS_KEY, array_merge( $this->settings(), $values ) );
	}

	public function get( string $key, $default = null ) {
		$settings = $this->settings();
		return $settings[ $key ] ?? $default;
	}
}
