Settings.php 622 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace Src;
  3. use Error;
  4. class Settings
  5. {
  6. private array $_settings;
  7. public function __construct(array $settings = [])
  8. {
  9. $this->_settings= $settings;
  10. }
  11. public function __get($key)
  12. {
  13. if (array_key_exists($key, $this->_settings)) {
  14. return $this->_settings[$key];
  15. }
  16. throw new Error('Property does not exist');
  17. }
  18. public function getRootPath(): string
  19. {
  20. return $this->path['root'] ? '/' . $this->path['root'] : '';
  21. }
  22. public function getViewsPath(): string
  23. {
  24. return '/' . $this->path['views'] ?? '';
  25. }
  26. }