settings.class.php 473 B

1234567891011121314151617181920
  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. private static $settings = [];
  19. }
  20. ?>