From 84ed545c6908543a896def482dc2e83ad481d9a4 Mon Sep 17 00:00:00 2001 From: Artur Welp Date: Thu, 20 Aug 2026 07:50:24 -0300 Subject: [PATCH] Addin a sandbox enviorment to test the Library --- run.sh | 4 ++ sandbox/app/routes/Routes.php | 10 ++++ sandbox/app/routes/RoutesController.php | 28 +++++++++ sandbox/app/users/clients/Client.php | 57 +++++++++++++++++++ .../app/users/clients/ClientsController.php | 54 ++++++++++++++++++ sandbox/app/users/clients/Config.php | 8 +++ sandbox/app/users/clients/Permission.php | 33 +++++++++++ sandbox/app/users/clients/Routes.php | 24 ++++++++ sandbox/bootstrap.php | 13 +++++ sandbox/includes.php | 26 +++++++++ sandbox/public/index.php | 3 + 11 files changed, 260 insertions(+) create mode 100755 run.sh create mode 100644 sandbox/app/routes/Routes.php create mode 100644 sandbox/app/routes/RoutesController.php create mode 100644 sandbox/app/users/clients/Client.php create mode 100644 sandbox/app/users/clients/ClientsController.php create mode 100644 sandbox/app/users/clients/Config.php create mode 100644 sandbox/app/users/clients/Permission.php create mode 100644 sandbox/app/users/clients/Routes.php create mode 100755 sandbox/bootstrap.php create mode 100644 sandbox/includes.php create mode 100644 sandbox/public/index.php diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..2424685 --- /dev/null +++ b/run.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +cd sandbox/public +sudo php -S 0.0.0.0:8081 \ No newline at end of file diff --git a/sandbox/app/routes/Routes.php b/sandbox/app/routes/Routes.php new file mode 100644 index 0000000..fc25c1b --- /dev/null +++ b/sandbox/app/routes/Routes.php @@ -0,0 +1,10 @@ +_verb) . " === $route->_uri"; + }, RouteCollection::getInstance()->_routes); + } + + function withTag(string $tag): array + { + return Array(); + } + + function fromGroup(string $group): array + { + return Array(); + } + +} diff --git a/sandbox/app/users/clients/Client.php b/sandbox/app/users/clients/Client.php new file mode 100644 index 0000000..12c7fff --- /dev/null +++ b/sandbox/app/users/clients/Client.php @@ -0,0 +1,57 @@ +id = $id; + $this->name = self::generateRandomName(); + } + + /** + * Generate a random Client Name + * + * @param int $id Id of the Client + * @return string + */ + public static function generateClient(int $id): Client + { + + return new Client($id); + } + + public static function generateRandomName(): string + { + $firstname = self::$listOfFirstNames[rand(0, sizeof(self::$listOfFirstNames) - 1)]; + $middleName = self::$listOfMiddleNames[rand(0, sizeof(self::$listOfMiddleNames) - 1)]; + $lastName = self::$listOfLastNames[rand(0, sizeof(self::$listOfLastNames) - 1)]; + + return "$firstname $middleName $lastName"; + } +} \ No newline at end of file diff --git a/sandbox/app/users/clients/ClientsController.php b/sandbox/app/users/clients/ClientsController.php new file mode 100644 index 0000000..acf6b2c --- /dev/null +++ b/sandbox/app/users/clients/ClientsController.php @@ -0,0 +1,54 @@ +id} - " . $client->name; + } + + function fullBuild(Client $client, Permission $permission, Config $config, bool $ignoreCache = true) + { + + } + + + function crazyTest(Client $client, Permission $permission, Config $config, bool $ignoreCache = true): Array + { + return [$client, $permission, $config, $ignoreCache]; + } + + function dump(Client $client, Permission $permission, Config $config, bool $ignoreCache = true): Array + { + return [$client, $permission, $config, $ignoreCache]; + } + +} diff --git a/sandbox/app/users/clients/Config.php b/sandbox/app/users/clients/Config.php new file mode 100644 index 0000000..9100324 --- /dev/null +++ b/sandbox/app/users/clients/Config.php @@ -0,0 +1,8 @@ + [ + "id" => 1, + "name" => "user-edit", + "displayName" => "Editar Usuário" + ], + "user-delete" => [ + "id" => 2, + "name" => "user-delete", + "displayName" => "Apagar Usuário" + ] + ]; + + function __construct(string $permission = ''){ + if(isset(self::$permissions[$permission])){ + $permission = (object) self::$permissions[$permission]; + + $this->id = $permission->id; + $this->name = $permission->name; + $this->displayName = $permission->displayName; + } + } +} \ No newline at end of file diff --git a/sandbox/app/users/clients/Routes.php b/sandbox/app/users/clients/Routes.php new file mode 100644 index 0000000..268b75b --- /dev/null +++ b/sandbox/app/users/clients/Routes.php @@ -0,0 +1,24 @@ +crawl(__DIR__ . "/app")->loadRoutes(); +RouteCollection::getInstance()->submit(); diff --git a/sandbox/includes.php b/sandbox/includes.php new file mode 100644 index 0000000..3b3b2ee --- /dev/null +++ b/sandbox/includes.php @@ -0,0 +1,26 @@ +