1
0

settings.class.php 562 B

1234567891011121314151617181920212223
  1. <?php
  2. namespace Juju;
  3. class Settings {
  4. public static function init(array $settings){
  5. array_walk($settings, function($val, $name){
  6. self::set($name, $val);
  7. });
  8. }
  9. public static function set(string $name, $val){
  10. self::$settings[$name] = $val;
  11. }
  12. public static function get(string $name){
  13. if(!isset(self::$settings[$name])){
  14. throw new \Exception("Setting not set");
  15. }
  16. return self::$settings[$name];
  17. }
  18. public static function has(string $name){
  19. return isset(self::$settings[$name]);
  20. }
  21. private static $settings = [];
  22. }
  23. ?>