Settings.php 920 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace Src;
  3. use Error;
  4. class Settings
  5. {
  6. private array $_settings;
  7. private static array $uris = [];
  8. public function __construct(array $settings = [])
  9. {
  10. $this->_settings= $settings;
  11. }
  12. public function __get($key)
  13. {
  14. if (array_key_exists($key, $this->_settings)) {
  15. return $this->_settings[$key];
  16. }
  17. throw new Error('Property does not exist');
  18. }
  19. public function getRootPath(): string
  20. {
  21. return $this->path['root'] ? '/' . $this->path['root'] : '';
  22. }
  23. public function getViewsPath(): string
  24. {
  25. return '/' . $this->path['views'] ?? '';
  26. }
  27. public function getDbSetting(): array {
  28. return $this->db ?? [];
  29. }
  30. public static function addUri($uri)
  31. {
  32. array_push(Settings::$uris, $uri);
  33. }
  34. public static function getUris()
  35. {
  36. return Settings::$uris;
  37. }
  38. }