<?php

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

class ServiceContainer {
	private $services = [];

	public function register($name, $instance) {
		$this->services[$name] = $instance;
		return $this;
	}

	public function get($name) {
		if (!isset($this->services[$name])) {
			throw new \Exception(esc_attr("Service '{$name}' not found"));
		}
		return $this->services[$name];
	}

	public function has($name) {
		return isset($this->services[$name]);
	}
}