Skip to content

Commit

Permalink
Update functions.php
Browse files Browse the repository at this point in the history
  • Loading branch information
juancristobalgd1 authored Aug 4, 2024
1 parent 40a21ff commit 0a52c25
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions src/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@
*/
function config(string $key = null, mixed $value = null)
{
if (null === $key) {
if (null === $key)
return new Config;
}

if (null !== $value) {
Config::set($key, $value);
Expand All @@ -36,13 +35,11 @@ function app(string $alias = null, mixed $value = null): object
{
$axmInstance = Axm::getApp();

if (null === $alias) {
if (null === $alias)
return $axmInstance;
}

if (null !== $value) {
if (null !== $value)
$axmInstance->$alias = $value;
}

return $axmInstance->$alias;
}
Expand Down Expand Up @@ -234,9 +231,8 @@ function lang(string $key, array $args = []): string
{
// Get an instance of Lang
$lang = Lang::make();
if (empty($args)) {
if (empty($args))
return $lang->trans($key);
}

return $lang->trans($key, $args);
}
Expand All @@ -263,9 +259,8 @@ function setFlash(string $type, string $message): void
function generateUrl(string $dir = ''): string
{
$url = baseUrl($dir);
if (!filter_var($url, FILTER_VALIDATE_URL)) {
if (!filter_var($url, FILTER_VALIDATE_URL))
throw new RuntimeException(sprintf('Invalid URL: %s', $url));
}

return $url;
}
Expand Down Expand Up @@ -370,9 +365,8 @@ function post($key = null)
if (!($post = app()->request->post()))
return false;

if ($key !== null) {
if ($key !== null)
return htmlspecialchars($post[$key], ENT_QUOTES, 'UTF-8');
}

return htmlspecialchars($post, ENT_QUOTES, 'UTF-8');
}
Expand Down Expand Up @@ -611,4 +605,4 @@ function csrf(): string
return '<input type="hidden" name="csrfToken" value="' . app()->getCsrfToken() . '">';
}

}
}

0 comments on commit 0a52c25

Please sign in to comment.