aboutsummaryrefslogtreecommitdiffstats
path: root/core/namespace/Factory.php
blob: e30895d9c261358d8a023a1b79f7a0722d208c39 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php
abstract class Factory implements FactoryInterface {
	public static $storage = [];

	#===============================================================================
	# Adds an instance of a class to the runtime instance cache
	#===============================================================================
	protected static function storeInstance($identifier, $instance) {
		return self::$storage[get_called_class()][$identifier] = $instance;
	}

	#===============================================================================
	# Gets an instance of a class from the runtime instance cache
	#===============================================================================
	protected static function fetchInstance($identifier) {
		return self::$storage[get_called_class()][$identifier] ?? false;
	}
}