Apply PHP Code Styling & Quality Changes (#1672)

Co-authored-by: FOSSBilling Bot <fossbilling-bot>
This commit is contained in:
FOSSBilling BotandFOSSBilling Bot authored and GitHub committed 2023-10-03 05:45:30 -07:00
1 parent 730333f448
commit d3f8cb3301
3 files changed
+13 -14

No files matched your search

+2 -6
View File
@@ -180,14 +180,10 @@ class i18n
{
if ($disabled) {
// Only get a list of the disabled locales
$locales = array_filter(glob(PATH_LANGS . DIRECTORY_SEPARATOR . '*'), function ($dir) {
return is_dir($dir) && file_exists($dir . DIRECTORY_SEPARATOR . '.disabled');
});
$locales = array_filter(glob(PATH_LANGS . DIRECTORY_SEPARATOR . '*'), fn($dir) => is_dir($dir) && file_exists($dir . DIRECTORY_SEPARATOR . '.disabled'));
} else {
// Only get a list of the enabled locales
$locales = array_filter(glob(PATH_LANGS . DIRECTORY_SEPARATOR . '*'), function ($dir) {
return is_dir($dir) && !file_exists($dir . DIRECTORY_SEPARATOR . '.disabled');
});
$locales = array_filter(glob(PATH_LANGS . DIRECTORY_SEPARATOR . '*'), fn($dir) => is_dir($dir) && !file_exists($dir . DIRECTORY_SEPARATOR . '.disabled'));
}
$locales = array_map('basename', $locales); // get only the directory name
+7 -3
View File
@@ -71,15 +71,16 @@ class Admin extends \Api_Abstract
public function languages(array $data): array
{
$data['disabled'] ??= false;
return \FOSSBilling\i18n::getLocales(true, $data['disabled']);
}
/**
* Toggles a given locale to either enable or disable it depending on it's current status.
*
*
* @param array $data The post data sent to the API. Should contain a key named `locale_id` which is set to the locale ID to change. (`en_US` for example)
*
* @throws \Box_Exception
*
* @throws \Box_Exception
*/
public function toggle_language(array $data): bool
{
@@ -88,11 +89,13 @@ class Admin extends \Api_Abstract
];
$this->di['validator']->checkRequiredParamsForArray($required, $data);
return \FOSSBilling\i18n::toggleLocale($data['locale_id']);
}
/**
* Returns how complete a given locale is.
*
* @param array $data $data The post data sent to the API. Should contain a key named `locale_id` which is set to the locale ID to get the completion percentage for. (`en_US` for example)
*/
public function locale_completion(array $data): int
@@ -102,6 +105,7 @@ class Admin extends \Api_Abstract
];
$this->di['validator']->checkRequiredParamsForArray($required, $data);
return \FOSSBilling\i18n::getLocaleCompletionPercent($data['locale_id']);
}
+4 -5
View File
@@ -10,10 +10,10 @@
namespace Box\Mod\System;
use FOSSBilling\Environment;
use Pimple\Container;
use Symfony\Component\HttpClient\HttpClient;
use Symfony\Contracts\Cache\ItemInterface;
use FOSSBilling\Environment;
class Service
{
@@ -221,7 +221,7 @@ class Service
{
$msgs = [];
// Check if there's an update available
// Check if there's an update available
try {
$updater = $this->di['updater'];
if ($updater->isUpdateAvailable()) {
@@ -236,16 +236,15 @@ class Service
error_log($e->getMessage());
}
$last_exec = $this->getParamValue('last_cron_exec');
$disableAutoCron = $this->di['config']['disable_auto_cron'] ?? false;
/**
/*
* Here we check if cron has been run at all or within a recent timeframe.
* No matter what, a message will be displayed within the dashboard and by default cron will also be performed to ensure functionality, however this can be disabled.
* Results are cached so even if `getMessages` is called multiple times it will still display correctly & so it won't go away before it's noticed.
*/
if ((Environment::isProduction())) {
if (Environment::isProduction()) {
$cronService = $this->di['mod_service']('cron');
$result = $this->di['cache']->get('cron_issue', function (ItemInterface $item) use ($cronService, $last_exec, $disableAutoCron) {