basePath = rtrim($basePath, '\/'); } $this->setControllerUris(); } /** * Create a new application instance following singleton pattern * * @return self */ public static function getInstance() { if (self::$instance == null) { self::$instance = new Application(__DIR__); } return self::$instance; ; } /** * Get the path to the public directory. * * @return string */ public function publicPath() { return $this->basePath.DIRECTORY_SEPARATOR.'public'; } /** * Get all available controller URIs * * @return array An array of all the available controller URIs */ public function setControllerUris() : void { $files = array_diff(scandir($this->basePath . '/Controllers'), ['..', '.']); $uris = []; foreach ($files as $file) { $withoutExtension = Str::before($file, 'Controller.php'); if (!$withoutExtension) { continue; } $uris[Str::snake($withoutExtension, '.')] = Str::before($file, '.php'); } $this->controllerUris = $uris; } /** * Get all available controller URIs * * @return array An array of all the available controller URIs */ public function getControllerUris() : array { return $this->controllerUris; } /** * Handles the response * */ public function respond() { return "
This is a very simple HTML document
It only has two paragraphs
"; } }