mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-18 23:50:09 +00:00
Various PSR12 code cleanup
This commit is contained in:
@@ -54,7 +54,7 @@ class AmountController extends Controller
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string) trans('firefly.piggyBanks'));
|
||||
app('view')->share('title', (string)trans('firefly.piggyBanks'));
|
||||
app('view')->share('mainTitleIcon', 'fa-bullseye');
|
||||
|
||||
$this->piggyRepos = app(PiggyBankRepositoryInterface::class);
|
||||
@@ -68,7 +68,7 @@ class AmountController extends Controller
|
||||
/**
|
||||
* Add money to piggy bank.
|
||||
*
|
||||
* @param PiggyBank $piggyBank
|
||||
* @param PiggyBank $piggyBank
|
||||
*
|
||||
* @return Factory|View
|
||||
*/
|
||||
@@ -89,7 +89,7 @@ class AmountController extends Controller
|
||||
/**
|
||||
* Add money to piggy bank (for mobile devices).
|
||||
*
|
||||
* @param PiggyBank $piggyBank
|
||||
* @param PiggyBank $piggyBank
|
||||
*
|
||||
* @return Factory|View
|
||||
*/
|
||||
@@ -113,8 +113,8 @@ class AmountController extends Controller
|
||||
/**
|
||||
* Add money to piggy bank.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param PiggyBank $piggyBank
|
||||
* @param Request $request
|
||||
* @param PiggyBank $piggyBank
|
||||
*
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
@@ -130,7 +130,7 @@ class AmountController extends Controller
|
||||
$this->piggyRepos->addAmount($piggyBank, $amount);
|
||||
session()->flash(
|
||||
'success',
|
||||
(string) trans(
|
||||
(string)trans(
|
||||
'firefly.added_amount_to_piggy',
|
||||
['amount' => app('amount')->formatAnything($currency, $amount, false), 'name' => $piggyBank->name]
|
||||
)
|
||||
@@ -140,10 +140,10 @@ class AmountController extends Controller
|
||||
return redirect(route('piggy-banks.index'));
|
||||
}
|
||||
|
||||
Log::error('Cannot add ' . $amount . ' because canAddAmount returned false.');
|
||||
Log::error('Cannot add '.$amount.' because canAddAmount returned false.');
|
||||
session()->flash(
|
||||
'error',
|
||||
(string) trans(
|
||||
(string)trans(
|
||||
'firefly.cannot_add_amount_piggy',
|
||||
['amount' => app('amount')->formatAnything($currency, $amount, false), 'name' => e($piggyBank->name)]
|
||||
)
|
||||
@@ -155,8 +155,8 @@ class AmountController extends Controller
|
||||
/**
|
||||
* Remove money from piggy bank.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param PiggyBank $piggyBank
|
||||
* @param Request $request
|
||||
* @param PiggyBank $piggyBank
|
||||
*
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
@@ -172,7 +172,7 @@ class AmountController extends Controller
|
||||
$this->piggyRepos->removeAmount($piggyBank, $amount);
|
||||
session()->flash(
|
||||
'success',
|
||||
(string) trans(
|
||||
(string)trans(
|
||||
'firefly.removed_amount_from_piggy',
|
||||
['amount' => app('amount')->formatAnything($currency, $amount, false), 'name' => $piggyBank->name]
|
||||
)
|
||||
@@ -181,11 +181,11 @@ class AmountController extends Controller
|
||||
|
||||
return redirect(route('piggy-banks.index'));
|
||||
}
|
||||
$amount = (string) $request->get('amount');
|
||||
$amount = (string)$request->get('amount');
|
||||
|
||||
session()->flash(
|
||||
'error',
|
||||
(string) trans(
|
||||
(string)trans(
|
||||
'firefly.cannot_remove_from_piggy',
|
||||
['amount' => app('amount')->formatAnything($currency, $amount, false), 'name' => e($piggyBank->name)]
|
||||
)
|
||||
@@ -197,7 +197,7 @@ class AmountController extends Controller
|
||||
/**
|
||||
* Remove money from piggy bank form.
|
||||
*
|
||||
* @param PiggyBank $piggyBank
|
||||
* @param PiggyBank $piggyBank
|
||||
*
|
||||
* @return Factory|View
|
||||
*/
|
||||
@@ -212,7 +212,7 @@ class AmountController extends Controller
|
||||
/**
|
||||
* Remove money from piggy bank (for mobile devices).
|
||||
*
|
||||
* @param PiggyBank $piggyBank
|
||||
* @param PiggyBank $piggyBank
|
||||
*
|
||||
* @return Factory|View
|
||||
*/
|
||||
|
||||
@@ -53,7 +53,7 @@ class CreateController extends Controller
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string) trans('firefly.piggyBanks'));
|
||||
app('view')->share('title', (string)trans('firefly.piggyBanks'));
|
||||
app('view')->share('mainTitleIcon', 'fa-bullseye');
|
||||
|
||||
$this->attachments = app(AttachmentHelperInterface::class);
|
||||
@@ -71,7 +71,7 @@ class CreateController extends Controller
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$subTitle = (string) trans('firefly.new_piggy_bank');
|
||||
$subTitle = (string)trans('firefly.new_piggy_bank');
|
||||
$subTitleIcon = 'fa-plus';
|
||||
|
||||
// put previous url in session if not redirect from store (not "create another").
|
||||
@@ -86,7 +86,7 @@ class CreateController extends Controller
|
||||
/**
|
||||
* Store a new piggy bank.
|
||||
*
|
||||
* @param PiggyBankStoreRequest $request
|
||||
* @param PiggyBankStoreRequest $request
|
||||
*
|
||||
* @return RedirectResponse|Redirector
|
||||
* @throws FireflyException
|
||||
@@ -99,7 +99,7 @@ class CreateController extends Controller
|
||||
}
|
||||
$piggyBank = $this->piggyRepos->store($data);
|
||||
|
||||
session()->flash('success', (string) trans('firefly.stored_piggy_bank', ['name' => $piggyBank->name]));
|
||||
session()->flash('success', (string)trans('firefly.stored_piggy_bank', ['name' => $piggyBank->name]));
|
||||
app('preferences')->mark();
|
||||
|
||||
// store attachment(s):
|
||||
@@ -109,7 +109,7 @@ class CreateController extends Controller
|
||||
$this->attachments->saveAttachmentsForModel($piggyBank, $files);
|
||||
}
|
||||
if (null !== $files && auth()->user()->hasRole('demo')) {
|
||||
session()->flash('info', (string) trans('firefly.no_att_demo_user'));
|
||||
session()->flash('info', (string)trans('firefly.no_att_demo_user'));
|
||||
}
|
||||
|
||||
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
|
||||
@@ -117,7 +117,7 @@ class CreateController extends Controller
|
||||
}
|
||||
$redirect = redirect($this->getPreviousUrl('piggy-banks.create.url'));
|
||||
|
||||
if (1 === (int) $request->get('create_another')) {
|
||||
if (1 === (int)$request->get('create_another')) {
|
||||
session()->put('piggy-banks.create.fromStore', true);
|
||||
|
||||
$redirect = redirect(route('piggy-banks.create'))->withInput();
|
||||
|
||||
@@ -49,7 +49,7 @@ class DeleteController extends Controller
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string) trans('firefly.piggyBanks'));
|
||||
app('view')->share('title', (string)trans('firefly.piggyBanks'));
|
||||
app('view')->share('mainTitleIcon', 'fa-bullseye');
|
||||
|
||||
$this->piggyRepos = app(PiggyBankRepositoryInterface::class);
|
||||
@@ -62,13 +62,13 @@ class DeleteController extends Controller
|
||||
/**
|
||||
* Delete a piggy bank.
|
||||
*
|
||||
* @param PiggyBank $piggyBank
|
||||
* @param PiggyBank $piggyBank
|
||||
*
|
||||
* @return Factory|View
|
||||
*/
|
||||
public function delete(PiggyBank $piggyBank)
|
||||
{
|
||||
$subTitle = (string) trans('firefly.delete_piggy_bank', ['name' => $piggyBank->name]);
|
||||
$subTitle = (string)trans('firefly.delete_piggy_bank', ['name' => $piggyBank->name]);
|
||||
|
||||
// put previous url in session
|
||||
$this->rememberPreviousUrl('piggy-banks.delete.url');
|
||||
@@ -79,13 +79,13 @@ class DeleteController extends Controller
|
||||
/**
|
||||
* Destroy the piggy bank.
|
||||
*
|
||||
* @param PiggyBank $piggyBank
|
||||
* @param PiggyBank $piggyBank
|
||||
*
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
public function destroy(PiggyBank $piggyBank): RedirectResponse
|
||||
{
|
||||
session()->flash('success', (string) trans('firefly.deleted_piggy_bank', ['name' => $piggyBank->name]));
|
||||
session()->flash('success', (string)trans('firefly.deleted_piggy_bank', ['name' => $piggyBank->name]));
|
||||
app('preferences')->mark();
|
||||
$this->piggyRepos->destroy($piggyBank);
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Http\Controllers\PiggyBank;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Models\PiggyBank;
|
||||
use FireflyIII\Repositories\ObjectGroup\OrganisesObjectGroups;
|
||||
@@ -35,6 +36,7 @@ use Illuminate\Contracts\View\Factory;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
use JsonException;
|
||||
use Symfony\Component\HttpFoundation\ParameterBag;
|
||||
|
||||
/**
|
||||
@@ -57,7 +59,7 @@ class IndexController extends Controller
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string) trans('firefly.piggyBanks'));
|
||||
app('view')->share('title', (string)trans('firefly.piggyBanks'));
|
||||
app('view')->share('mainTitleIcon', 'fa-bullseye');
|
||||
|
||||
$this->piggyRepos = app(PiggyBankRepositoryInterface::class);
|
||||
@@ -72,11 +74,11 @@ class IndexController extends Controller
|
||||
*
|
||||
* TODO very complicated function.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Factory|View
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
* @throws \JsonException
|
||||
* @throws FireflyException
|
||||
* @throws JsonException
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
@@ -104,16 +106,16 @@ class IndexController extends Controller
|
||||
/** @var PiggyBank $piggy */
|
||||
foreach ($collection as $piggy) {
|
||||
$array = $transformer->transform($piggy);
|
||||
$groupOrder = (int) $array['object_group_order'];
|
||||
$groupOrder = (int)$array['object_group_order'];
|
||||
// make group array if necessary:
|
||||
$piggyBanks[$groupOrder] = $piggyBanks[$groupOrder] ?? [
|
||||
'object_group_id' => $array['object_group_id'] ?? 0,
|
||||
'object_group_title' => $array['object_group_title'] ?? trans('firefly.default_group_title_name'),
|
||||
'piggy_banks' => [],
|
||||
];
|
||||
'object_group_id' => $array['object_group_id'] ?? 0,
|
||||
'object_group_title' => $array['object_group_title'] ?? trans('firefly.default_group_title_name'),
|
||||
'piggy_banks' => [],
|
||||
];
|
||||
|
||||
$account = $accountTransformer->transform($piggy->account);
|
||||
$accountId = (int) $account['id'];
|
||||
$accountId = (int)$account['id'];
|
||||
$array['attachments'] = $this->piggyRepos->getAttachments($piggy);
|
||||
if (!array_key_exists($accountId, $accounts)) {
|
||||
// create new:
|
||||
@@ -143,7 +145,7 @@ class IndexController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $piggyBanks
|
||||
* @param array $piggyBanks
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -155,23 +157,23 @@ class IndexController extends Controller
|
||||
foreach ($group['piggy_banks'] as $piggy) {
|
||||
$currencyId = $piggy['currency_id'];
|
||||
$sums[$groupId][$currencyId] = $sums[$groupId][$currencyId] ?? [
|
||||
'target' => '0',
|
||||
'saved' => '0',
|
||||
'left_to_save' => '0',
|
||||
'save_per_month' => '0',
|
||||
'currency_id' => $currencyId,
|
||||
'currency_code' => $piggy['currency_code'],
|
||||
'currency_symbol' => $piggy['currency_symbol'],
|
||||
'currency_decimal_places' => $piggy['currency_decimal_places'],
|
||||
];
|
||||
'target' => '0',
|
||||
'saved' => '0',
|
||||
'left_to_save' => '0',
|
||||
'save_per_month' => '0',
|
||||
'currency_id' => $currencyId,
|
||||
'currency_code' => $piggy['currency_code'],
|
||||
'currency_symbol' => $piggy['currency_symbol'],
|
||||
'currency_decimal_places' => $piggy['currency_decimal_places'],
|
||||
];
|
||||
// target_amount
|
||||
// current_amount
|
||||
// left_to_save
|
||||
// save_per_month
|
||||
$sums[$groupId][$currencyId]['target'] = bcadd($sums[$groupId][$currencyId]['target'], (string) $piggy['target_amount']);
|
||||
$sums[$groupId][$currencyId]['saved'] = bcadd($sums[$groupId][$currencyId]['saved'], (string) $piggy['current_amount']);
|
||||
$sums[$groupId][$currencyId]['left_to_save'] = bcadd($sums[$groupId][$currencyId]['left_to_save'], (string) $piggy['left_to_save']);
|
||||
$sums[$groupId][$currencyId]['save_per_month'] = bcadd($sums[$groupId][$currencyId]['save_per_month'], (string) $piggy['save_per_month']);
|
||||
$sums[$groupId][$currencyId]['target'] = bcadd($sums[$groupId][$currencyId]['target'], (string)$piggy['target_amount']);
|
||||
$sums[$groupId][$currencyId]['saved'] = bcadd($sums[$groupId][$currencyId]['saved'], (string)$piggy['current_amount']);
|
||||
$sums[$groupId][$currencyId]['left_to_save'] = bcadd($sums[$groupId][$currencyId]['left_to_save'], (string)$piggy['left_to_save']);
|
||||
$sums[$groupId][$currencyId]['save_per_month'] = bcadd($sums[$groupId][$currencyId]['save_per_month'], (string)$piggy['save_per_month']);
|
||||
}
|
||||
}
|
||||
foreach ($piggyBanks as $groupOrder => $group) {
|
||||
@@ -185,15 +187,15 @@ class IndexController extends Controller
|
||||
/**
|
||||
* Set the order of a piggy bank.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param PiggyBank $piggyBank
|
||||
* @param Request $request
|
||||
* @param PiggyBank $piggyBank
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function setOrder(Request $request, PiggyBank $piggyBank): JsonResponse
|
||||
{
|
||||
$objectGroupTitle = (string) $request->get('objectGroupTitle');
|
||||
$newOrder = (int) $request->get('order');
|
||||
$objectGroupTitle = (string)$request->get('objectGroupTitle');
|
||||
$newOrder = (int)$request->get('order');
|
||||
$this->piggyRepos->setOrder($piggyBank, $newOrder);
|
||||
if ('' !== $objectGroupTitle) {
|
||||
$this->piggyRepos->setObjectGroup($piggyBank, $objectGroupTitle);
|
||||
|
||||
@@ -51,7 +51,7 @@ class ShowController extends Controller
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string) trans('firefly.piggyBanks'));
|
||||
app('view')->share('title', (string)trans('firefly.piggyBanks'));
|
||||
app('view')->share('mainTitleIcon', 'fa-bullseye');
|
||||
|
||||
$this->piggyRepos = app(PiggyBankRepositoryInterface::class);
|
||||
@@ -64,7 +64,7 @@ class ShowController extends Controller
|
||||
/**
|
||||
* Show a single piggy bank.
|
||||
*
|
||||
* @param PiggyBank $piggyBank
|
||||
* @param PiggyBank $piggyBank
|
||||
*
|
||||
* @return Factory|View
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user