Application.php 581 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. namespace Src;
  3. use Error;
  4. class Application
  5. {
  6. private Settings $settings;
  7. private Route $route;
  8. public function __construct(Settings $settings)
  9. {
  10. $this->settings = $settings;
  11. $this->route = new Route();
  12. }
  13. public function __get($key)
  14. {
  15. if ($key === 'settings') {
  16. return $this->settings;
  17. }
  18. throw new Error('Accessing a non-existent property');
  19. }
  20. public function run(): void
  21. {
  22. $this->route->setPrefix($this->settings->getRootPath());
  23. $this->route->start();
  24. }
  25. }