refactor: code style changes
Signed-off-by: miguel456 <me@nogueira.codes>
This commit is contained in:
@@ -1,28 +1,21 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
|
||||
use App\Exceptions\InvalidGamePreferenceException;
|
||||
use App\Exceptions\OptionNotFoundException;
|
||||
use App\Facades\Options;
|
||||
use Illuminate\Auth\Authenticatable;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class ConfigurationService
|
||||
{
|
||||
|
||||
/**
|
||||
* @throws OptionNotFoundException|\Exception
|
||||
*
|
||||
*/
|
||||
public function saveConfiguration($configuration) {
|
||||
|
||||
public function saveConfiguration($configuration)
|
||||
{
|
||||
foreach ($configuration as $optionName => $option) {
|
||||
try {
|
||||
|
||||
Log::debug('Going through option '.$optionName);
|
||||
if (Options::optionExists($optionName)) {
|
||||
Log::debug('Option exists, updating to new values', [
|
||||
@@ -31,9 +24,7 @@ class ConfigurationService
|
||||
]);
|
||||
Options::changeOption($optionName, $option);
|
||||
}
|
||||
|
||||
} catch (\Exception $ex) {
|
||||
|
||||
Log::error('Unable to update options!', [
|
||||
'msg' => $ex->getMessage(),
|
||||
'trace' => $ex->getTraceAsString(),
|
||||
@@ -49,27 +40,26 @@ class ConfigurationService
|
||||
* Saves the chosen game integration
|
||||
*
|
||||
* @throws InvalidGamePreferenceException
|
||||
*
|
||||
* @returns bool
|
||||
*/
|
||||
public function saveGameIntegration($gamePreference): bool
|
||||
{
|
||||
|
||||
// TODO: Find solution to dynamically support games
|
||||
|
||||
$supportedGames = [
|
||||
'RUST',
|
||||
'MINECRAFT',
|
||||
'SE',
|
||||
'GMOD'
|
||||
'GMOD',
|
||||
];
|
||||
|
||||
if (!is_null($gamePreference) && in_array($gamePreference, $supportedGames))
|
||||
{
|
||||
if (! is_null($gamePreference) && in_array($gamePreference, $supportedGames)) {
|
||||
Options::changeOption('currentGame', $gamePreference);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
throw new InvalidGamePreferenceException("Unsupported game " . $gamePreference);
|
||||
throw new InvalidGamePreferenceException('Unsupported game '.$gamePreference);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user