summaryrefslogtreecommitdiffstats
path: root/core/namespace/Factory.php
blob: 779b890958250bf73a87c2459cdc977b49dc7208 (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;
	}
}