<?php

namespace Planaday\Utility;

class AutoLoader {
	public function __construct(
		protected string $pluginRoot
	) {
		spl_autoload_register([$this, 'loadClass']);
	}

	public function loadClass(string $className):void {
		$classPath = str_replace('\\' , '/', $className);
		$filePath = $this->pluginRoot . '/' . $classPath . '.php';

		if (file_exists($filePath)){
			include_once $filePath;
		}
	}
}