<?php

namespace Planaday\Utility\DependencyInjection;

class ConstructorRegister {
	/** @var array<class-string, callable():object> */
	protected array $constructors = [];

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

	/**
	 * @template C
	 * @template I of C
	 * @param class-string<C> $class
	 * @param callable(Scope):I $constructor
	 *
	 * @return void
	 */
	public function set(string $class, callable $constructor): void{
		$this->constructors[$class] = $constructor;
	}
}