I am trying to create my own sort of lightweight,yet OOP way to keep track of loaded files and their appropriate versions (not yet implemented) in my PHP framework to be able to easily test dependency issues in the future.
Here's my current code, but being a total newcomer to OOP and patterns I am not able to determine if I have accomplished a proper Singleton or not:
class loadRegistry {
private static $registry = null;
private function __construct(){
if (is_null(self::$registry));
self::$registry = array();
}
public static function get() {
return self::$registry;
}
public static function set($filename){
if ( isSet( self::$registry[$filename]) AND !empty($filename) ) {
throw new Exception("File already loaded");
}
else self::$registry[$filename] = '';
}
}
loadRegistry::set('filename');
loadRegistry::set('filename2');
$reg = loadRegistry::get();