<?php

namespace Bright_Deposits_For_WooCommerce\Core;

/**
 * Class ContainerManager
 * @package Bright_Deposits_For_WooCommerce\Core
 * @since 1.0.0
 * @author Bright Plugins
 * Description: This class is responsible for managing the container for the plugin.
 */
class ContainerManager {
    protected static $factories = [];

    /**
     * Register a new factory for the container.
     * @since 1.0.0
     * @param string $key
     * @param callable $factory
     * @return void
     */
    public static function register(string $key, callable $factory): void {
        self::$factories[$key] = $factory;
    }

    /**
     * Get a factory from the container.
     * @since 1.0.0
     * @param string $key
     * @return callable|null
     */
    public static function get(string $key) {
        return isset(self::$factories[$key]) ? self::$factories[$key]() : null;
    }
}
