Skip to content

Commit

Permalink
updates files
Browse files Browse the repository at this point in the history
  • Loading branch information
juancristobalgd1 authored Dec 24, 2023
1 parent 91c3172 commit e0592f6
Show file tree
Hide file tree
Showing 7 changed files with 306 additions and 268 deletions.
49 changes: 13 additions & 36 deletions src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,9 @@ private function init(): void
$this->getContainer()
->loadFromDirectory(APP_PATH . DIRECTORY_SEPARATOR . 'Providers');

$this->openDefaultSystemConfigurationFiles();
$this->openRoutesUser();
}

/**
* Open the default system configuration files.
*/
private function openDefaultSystemConfigurationFiles(): void
{
$path = APP_PATH . DIRECTORY_SEPARATOR . 'Config';
$this->config->load($path . DIRECTORY_SEPARATOR . 'App.php');
$this->config->load($path . DIRECTORY_SEPARATOR . 'Paths.php');
}

/**
* Get the application configuration.
*
Expand All @@ -86,17 +75,8 @@ private function openDefaultSystemConfigurationFiles(): void
*/
public function config(string $key = null, $rootBaseConfig = null)
{
$config = Axm\BaseConfig::make();
if (is_null($key))
return $config;

if (str_contains($key, '/')) {
$path = is_null($rootBaseConfig) ? $config::ROOT_PATH_CONFIG .
$key : $rootBaseConfig;
return $config->load($path);
}

return $config->get($key);
// return $config->get($key);
return config($key, $rootBaseConfig);
}

/**
Expand All @@ -108,9 +88,7 @@ public function openRoutesUser(): void
$files = glob(ROOT_PATH . DIRECTORY_SEPARATOR .
'routes' . DIRECTORY_SEPARATOR . "*$ext");

foreach ($files as $file) {
include_once($file);
}
foreach ($files as $file) include_once($file);
}

/**
Expand Down Expand Up @@ -204,9 +182,10 @@ public function simpleKeyLogin(array $data): bool
}

/**
* @param array $keys
* @param array $values
*
* multipleKeyLogin
*
* @param mixed $keys
* @param mixed $values
* @return bool
*/
public function multipleKeyLogin(array $keys, array $values): bool
Expand Down Expand Up @@ -266,7 +245,7 @@ public function login(array $fields, array $values = []): bool
return $check;
} catch (\Throwable $th) {
// Handle errors and throw a more descriptive exception
throw new \Exception("Error during login: " . $th->getMessage());
throw new Exception(sprintf('Error during login: %s', $th->getMessage()));
}
}

Expand Down Expand Up @@ -464,8 +443,7 @@ public function getHelpers(): array
*/
public function user(string $value = null)
{
if (is_null($value))
return $this->container->get('user');
if (is_null($value)) return $this->container->get('user');

return $this->container
->get('user')
Expand Down Expand Up @@ -554,11 +532,10 @@ public function removeService(string $alias)
*/
public function __get($name)
{
if ($name === 'user') {
$this->setUser();
}

return $this->container->get($name);
return match ($name) {
($name === 'user') => $this->setUser(),
default => $this->container->get($name),
};
}

/**
Expand Down
Loading

0 comments on commit e0592f6

Please sign in to comment.