Various PSR12 code cleanup

This commit is contained in:
James Cole
2022-12-29 19:41:57 +01:00
parent 0022009dd5
commit dbf3e76ecc
340 changed files with 4079 additions and 3816 deletions

View File

@@ -65,7 +65,7 @@ class DestroyController extends Controller
*
* Remove the specified resource from storage.
*
* @param TransactionCurrency $currency
* @param TransactionCurrency $currency
*
* @return JsonResponse
* @throws FireflyException

View File

@@ -93,8 +93,8 @@ class ListController extends Controller
* https://api-docs.firefly-iii.org/#/currencies/listAccountByCurrency
* Display a list of accounts.
*
* @param Request $request
* @param TransactionCurrency $currency
* @param Request $request
* @param TransactionCurrency $currency
*
* @return JsonResponse
* @throws FireflyException
@@ -110,7 +110,7 @@ class ListController extends Controller
// types to get, page size:
$types = $this->mapAccountTypes($this->parameters->get('type'));
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
// get list of accounts. Count it and split it.
/** @var AccountRepositoryInterface $accountRepository */
@@ -120,7 +120,7 @@ class ListController extends Controller
// filter list on currency preference:
$collection = $unfiltered->filter(
static function (Account $account) use ($currency, $accountRepository) {
$currencyId = (int) $accountRepository->getMetaValue($account, 'currency_id');
$currencyId = (int)$accountRepository->getMetaValue($account, 'currency_id');
return $currencyId === $currency->id;
}
@@ -131,7 +131,7 @@ class ListController extends Controller
// make paginator:
$paginator = new LengthAwarePaginator($accounts, $count, $pageSize, $this->parameters->get('page'));
$paginator->setPath(route('api.v1.currencies.accounts', [$currency->code]) . $this->buildParams());
$paginator->setPath(route('api.v1.currencies.accounts', [$currency->code]).$this->buildParams());
/** @var AccountTransformer $transformer */
$transformer = app(AccountTransformer::class);
@@ -148,7 +148,7 @@ class ListController extends Controller
*
* Display a listing of the resource.
*
* @param TransactionCurrency $currency
* @param TransactionCurrency $currency
*
* @return JsonResponse
* @throws FireflyException
@@ -158,7 +158,7 @@ class ListController extends Controller
{
$manager = $this->getManager();
// types to get, page size:
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
// get list of available budgets. Count it and split it.
/** @var AvailableBudgetRepositoryInterface $abRepository */
@@ -169,7 +169,7 @@ class ListController extends Controller
$availableBudgets = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
// make paginator:
$paginator = new LengthAwarePaginator($availableBudgets, $count, $pageSize, $this->parameters->get('page'));
$paginator->setPath(route('api.v1.currencies.available_budgets', [$currency->code]) . $this->buildParams());
$paginator->setPath(route('api.v1.currencies.available_budgets', [$currency->code]).$this->buildParams());
/** @var AvailableBudgetTransformer $transformer */
$transformer = app(AvailableBudgetTransformer::class);
@@ -187,7 +187,7 @@ class ListController extends Controller
*
* List all bills
*
* @param TransactionCurrency $currency
* @param TransactionCurrency $currency
*
* @return JsonResponse
* @throws FireflyException
@@ -199,7 +199,7 @@ class ListController extends Controller
/** @var BillRepositoryInterface $billRepos */
$billRepos = app(BillRepositoryInterface::class);
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$unfiltered = $billRepos->getBills();
// filter and paginate list:
@@ -213,7 +213,7 @@ class ListController extends Controller
// make paginator:
$paginator = new LengthAwarePaginator($bills, $count, $pageSize, $this->parameters->get('page'));
$paginator->setPath(route('api.v1.currencies.bills', [$currency->code]) . $this->buildParams());
$paginator->setPath(route('api.v1.currencies.bills', [$currency->code]).$this->buildParams());
/** @var BillTransformer $transformer */
$transformer = app(BillTransformer::class);
@@ -231,7 +231,7 @@ class ListController extends Controller
*
* List all budget limits
*
* @param TransactionCurrency $currency
* @param TransactionCurrency $currency
*
* @return JsonResponse
* @throws FireflyException
@@ -243,12 +243,12 @@ class ListController extends Controller
$blRepository = app(BudgetLimitRepositoryInterface::class);
$manager = $this->getManager();
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$collection = $blRepository->getAllBudgetLimitsByCurrency($currency, $this->parameters->get('start'), $this->parameters->get('end'));
$count = $collection->count();
$budgetLimits = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
$paginator = new LengthAwarePaginator($budgetLimits, $count, $pageSize, $this->parameters->get('page'));
$paginator->setPath(route('api.v1.currencies.budget_limits', [$currency->code]) . $this->buildParams());
$paginator->setPath(route('api.v1.currencies.budget_limits', [$currency->code]).$this->buildParams());
/** @var BudgetLimitTransformer $transformer */
$transformer = app(BudgetLimitTransformer::class);
@@ -266,7 +266,7 @@ class ListController extends Controller
*
* List all recurring transactions.
*
* @param TransactionCurrency $currency
* @param TransactionCurrency $currency
*
* @return JsonResponse
* @throws FireflyException
@@ -276,7 +276,7 @@ class ListController extends Controller
{
$manager = $this->getManager();
// types to get, page size:
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
// get list of budgets. Count it and split it.
/** @var RecurringRepositoryInterface $recurringRepos */
@@ -301,7 +301,7 @@ class ListController extends Controller
// make paginator:
$paginator = new LengthAwarePaginator($piggyBanks, $count, $pageSize, $this->parameters->get('page'));
$paginator->setPath(route('api.v1.currencies.recurrences', [$currency->code]) . $this->buildParams());
$paginator->setPath(route('api.v1.currencies.recurrences', [$currency->code]).$this->buildParams());
/** @var RecurrenceTransformer $transformer */
$transformer = app(RecurrenceTransformer::class);
@@ -319,7 +319,7 @@ class ListController extends Controller
*
* List all of them.
*
* @param TransactionCurrency $currency
* @param TransactionCurrency $currency
*
* @return JsonResponse
* @throws FireflyException
@@ -328,7 +328,7 @@ class ListController extends Controller
public function rules(TransactionCurrency $currency): JsonResponse
{
$manager = $this->getManager();
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
// get list of budgets. Count it and split it.
/** @var RuleRepositoryInterface $ruleRepos */
@@ -353,7 +353,7 @@ class ListController extends Controller
// make paginator:
$paginator = new LengthAwarePaginator($rules, $count, $pageSize, $this->parameters->get('page'));
$paginator->setPath(route('api.v1.rules.index') . $this->buildParams());
$paginator->setPath(route('api.v1.rules.index').$this->buildParams());
/** @var RuleTransformer $transformer */
$transformer = app(RuleTransformer::class);
@@ -371,9 +371,9 @@ class ListController extends Controller
*
* Show all transactions.
*
* @param Request $request
* @param Request $request
*
* @param TransactionCurrency $currency
* @param TransactionCurrency $currency
*
* @return JsonResponse
* @throws FireflyException
@@ -381,7 +381,7 @@ class ListController extends Controller
*/
public function transactions(Request $request, TransactionCurrency $currency): JsonResponse
{
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$type = $request->get('type') ?? 'default';
$this->parameters->set('type', $type);
@@ -410,7 +410,7 @@ class ListController extends Controller
$collector->setRange($this->parameters->get('start'), $this->parameters->get('end'));
}
$paginator = $collector->getPaginatedGroups();
$paginator->setPath(route('api.v1.currencies.transactions', [$currency->code]) . $this->buildParams());
$paginator->setPath(route('api.v1.currencies.transactions', [$currency->code]).$this->buildParams());
$transactions = $paginator->getCollection();
/** @var TransactionGroupTransformer $transformer */

View File

@@ -79,13 +79,13 @@ class ShowController extends Controller
*/
public function index(): JsonResponse
{
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$collection = $this->repository->getAll();
$count = $collection->count();
// slice them:
$currencies = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
$paginator = new LengthAwarePaginator($currencies, $count, $pageSize, $this->parameters->get('page'));
$paginator->setPath(route('api.v1.currencies.index') . $this->buildParams());
$paginator->setPath(route('api.v1.currencies.index').$this->buildParams());
$manager = $this->getManager();
$defaultCurrency = app('amount')->getDefaultCurrencyByUser(auth()->user());
$this->parameters->set('defaultCurrency', $defaultCurrency);
@@ -106,7 +106,7 @@ class ShowController extends Controller
*
* Show a currency.
*
* @param TransactionCurrency $currency
* @param TransactionCurrency $currency
*
* @return JsonResponse
* @throws FireflyException

View File

@@ -72,7 +72,7 @@ class StoreController extends Controller
*
* Store new currency.
*
* @param StoreRequest $request
* @param StoreRequest $request
*
* @return JsonResponse
* @throws FireflyException

View File

@@ -73,7 +73,7 @@ class UpdateController extends Controller
*
* Disable a currency.
*
* @param TransactionCurrency $currency
* @param TransactionCurrency $currency
*
* @return JsonResponse
* @throws FireflyException
@@ -101,43 +101,13 @@ class UpdateController extends Controller
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/#/currencies/enableCurrency
*
* Enable a currency.
*
* @param TransactionCurrency $currency
*
* @return JsonResponse
* @throws FireflyException
* @throws JsonException
* @codeCoverageIgnore
*/
public function enable(TransactionCurrency $currency): JsonResponse
{
$this->repository->enable($currency);
$manager = $this->getManager();
$defaultCurrency = app('amount')->getDefaultCurrencyByUser(auth()->user());
$this->parameters->set('defaultCurrency', $defaultCurrency);
/** @var CurrencyTransformer $transformer */
$transformer = app(CurrencyTransformer::class);
$transformer->setParameters($this->parameters);
$resource = new Item($currency, $transformer, 'currencies');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/#/currencies/defaultCurrency
*
* Make the currency a default currency.
*
* @param TransactionCurrency $currency
* @param TransactionCurrency $currency
*
* @return JsonResponse
* @throws FireflyException
@@ -163,14 +133,44 @@ class UpdateController extends Controller
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/#/currencies/enableCurrency
*
* Enable a currency.
*
* @param TransactionCurrency $currency
*
* @return JsonResponse
* @throws FireflyException
* @throws JsonException
* @codeCoverageIgnore
*/
public function enable(TransactionCurrency $currency): JsonResponse
{
$this->repository->enable($currency);
$manager = $this->getManager();
$defaultCurrency = app('amount')->getDefaultCurrencyByUser(auth()->user());
$this->parameters->set('defaultCurrency', $defaultCurrency);
/** @var CurrencyTransformer $transformer */
$transformer = app(CurrencyTransformer::class);
$transformer->setParameters($this->parameters);
$resource = new Item($currency, $transformer, 'currencies');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/#/currencies/updateCurrency
*
* Update a currency.
*
* @param UpdateRequest $request
* @param TransactionCurrency $currency
* @param UpdateRequest $request
* @param TransactionCurrency $currency
*
* @return JsonResponse
* @throws FireflyException