<?php

namespace Planaday\Utility\DependencyInjection;

class ComponentRegister {
	/** @var array<class-string, object> */
	protected array $components = [];

	/**
	 * @template C
	 * @param class-string<C> $class
	 *
	 * @return C|null
	 */
	public function get(string $class){
		return $this->components[$class] ?? null;
	}

	/**
	 * @template C
	 * @template I of C
	 * @param class-string<C> $class
	 * @param I|null $object
	 *
	 * @return void
	 */
	public function set(string $class, $object): void{
		$this->components[$class] = $object;
	}

	public function __destruct(){
		$this->components = [];
	}
}