Guest User

Untitled

a guest
Apr 26th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. <?php
  2. define('CONFIG_PATHS', 'path');
  3. define('CONFIG_URLS', 'url');
  4. define('CONFIG_DATABASE', 'db');
  5. define('CONFIG_LOGGING', 'log');
  6.  
  7. class Config {
  8. private static $instance = null;
  9. private $storage;
  10.  
  11. function __construct () {
  12. $this->storage = array();
  13. }
  14.  
  15. public static function GetInstance () {
  16. if (self::$instance === null) {
  17. $className = __CLASS__;
  18. self::$instance = new $className();
  19. }
  20. return(self::$instance);
  21. }
  22.  
  23. function setVal ($sNameSpace, $sKey, $sVal) {
  24. if (is_null($sKey))
  25. $this->storage[$sNameSpace][] = $sVal;
  26. else
  27. $this->storage[$sNameSpace][$sKey] = $sVal;
  28. }
  29.  
  30. function getVal ($sNameSpace, $sKey) {
  31. if (!array_key_exists($sNameSpace, $this->storage)) return '';
  32. if (!array_key_exists($sKey, $this->storage[$sNameSpace])) return '';
  33. return $this->storage[$sNameSpace][$sKey];
  34. }
  35.  
  36. function getVals ($sNameSpace) {
  37. if (!array_key_exists($sNameSpace, $this->storage)) return array();
  38. return array_keys($this->storage[$sNameSpace]);
  39. }
  40.  
  41. function hasVal ($sNameSpace, $sKey) {
  42. return array_key_exists($sKey, $this->storage[$sNameSpace]);
  43. }
  44.  
  45. function delVal ($sNameSpace, $sKey) {
  46. unset($this->storage[$sNameSpace][$sKey]);
  47. }
  48. }
  49. ?>
Add Comment
Please, Sign In to add comment