mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-18 15:39:50 +00:00
Various PSR12 code cleanup
This commit is contained in:
@@ -26,7 +26,6 @@ namespace FireflyIII\Http\Controllers\Rule;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Http\Requests\RuleFormRequest;
|
||||
use FireflyIII\Models\Bill;
|
||||
use FireflyIII\Models\Rule;
|
||||
use FireflyIII\Models\RuleGroup;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Rule\RuleRepositoryInterface;
|
||||
@@ -61,7 +60,7 @@ class CreateController extends Controller
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string) trans('firefly.rules'));
|
||||
app('view')->share('title', (string)trans('firefly.rules'));
|
||||
app('view')->share('mainTitleIcon', 'fa-random');
|
||||
|
||||
$this->ruleRepos = app(RuleRepositoryInterface::class);
|
||||
@@ -74,8 +73,8 @@ class CreateController extends Controller
|
||||
/**
|
||||
* Create a new rule. It will be stored under the given $ruleGroup.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param RuleGroup|null $ruleGroup
|
||||
* @param Request $request
|
||||
* @param RuleGroup|null $ruleGroup
|
||||
*
|
||||
* @return Factory|View
|
||||
*/
|
||||
@@ -89,7 +88,7 @@ class CreateController extends Controller
|
||||
$oldActions = [];
|
||||
|
||||
// build triggers from query, if present.
|
||||
$query = (string) $request->get('from_query');
|
||||
$query = (string)$request->get('from_query');
|
||||
if ('' !== $query) {
|
||||
$search = app(SearchInterface::class);
|
||||
$search->parseQuery($query);
|
||||
@@ -113,9 +112,9 @@ class CreateController extends Controller
|
||||
$subTitleIcon = 'fa-clone';
|
||||
|
||||
// title depends on whether or not there is a rule group:
|
||||
$subTitle = (string) trans('firefly.make_new_rule_no_group');
|
||||
$subTitle = (string)trans('firefly.make_new_rule_no_group');
|
||||
if (null !== $ruleGroup) {
|
||||
$subTitle = (string) trans('firefly.make_new_rule', ['title' => $ruleGroup->title]);
|
||||
$subTitle = (string)trans('firefly.make_new_rule', ['title' => $ruleGroup->title]);
|
||||
}
|
||||
|
||||
// flash old data
|
||||
@@ -136,20 +135,20 @@ class CreateController extends Controller
|
||||
/**
|
||||
* Create a new rule. It will be stored under the given $ruleGroup.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Bill $bill
|
||||
* @param Request $request
|
||||
* @param Bill $bill
|
||||
*
|
||||
* @return Factory|View
|
||||
*/
|
||||
public function createFromBill(Request $request, Bill $bill)
|
||||
{
|
||||
$request->session()->flash('info', (string) trans('firefly.instructions_rule_from_bill', ['name' => e($bill->name)]));
|
||||
$request->session()->flash('info', (string)trans('firefly.instructions_rule_from_bill', ['name' => e($bill->name)]));
|
||||
|
||||
$this->createDefaultRuleGroup();
|
||||
$preFilled = [
|
||||
'strict' => true,
|
||||
'title' => (string) trans('firefly.new_rule_for_bill_title', ['name' => $bill->name]),
|
||||
'description' => (string) trans('firefly.new_rule_for_bill_description', ['name' => $bill->name]),
|
||||
'title' => (string)trans('firefly.new_rule_for_bill_title', ['name' => $bill->name]),
|
||||
'description' => (string)trans('firefly.new_rule_for_bill_description', ['name' => $bill->name]),
|
||||
];
|
||||
|
||||
// make triggers and actions from the bill itself.
|
||||
@@ -169,7 +168,7 @@ class CreateController extends Controller
|
||||
$subTitleIcon = 'fa-clone';
|
||||
|
||||
// title depends on whether or not there is a rule group:
|
||||
$subTitle = (string) trans('firefly.make_new_rule_no_group');
|
||||
$subTitle = (string)trans('firefly.make_new_rule_no_group');
|
||||
|
||||
// flash old data
|
||||
$request->session()->flash('preFilled', $preFilled);
|
||||
@@ -187,17 +186,17 @@ class CreateController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param TransactionJournal $journal
|
||||
* @param Request $request
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return Factory|\Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function createFromJournal(Request $request, TransactionJournal $journal)
|
||||
{
|
||||
$request->session()->flash('info', (string) trans('firefly.instructions_rule_from_journal', ['name' => e($journal->description)]));
|
||||
$request->session()->flash('info', (string)trans('firefly.instructions_rule_from_journal', ['name' => e($journal->description)]));
|
||||
|
||||
$subTitleIcon = 'fa-clone';
|
||||
$subTitle = (string) trans('firefly.make_new_rule_no_group');
|
||||
$subTitle = (string)trans('firefly.make_new_rule_no_group');
|
||||
|
||||
// get triggers and actions for journal.
|
||||
$oldTriggers = $this->getTriggersForJournal($journal);
|
||||
@@ -208,8 +207,8 @@ class CreateController extends Controller
|
||||
// collect pre-filled information:
|
||||
$preFilled = [
|
||||
'strict' => true,
|
||||
'title' => (string) trans('firefly.new_rule_for_journal_title', ['description' => $journal->description]),
|
||||
'description' => (string) trans('firefly.new_rule_for_journal_description', ['description' => $journal->description]),
|
||||
'title' => (string)trans('firefly.new_rule_for_journal_title', ['description' => $journal->description]),
|
||||
'description' => (string)trans('firefly.new_rule_for_journal_description', ['description' => $journal->description]),
|
||||
];
|
||||
|
||||
// restore actions and triggers from old input:
|
||||
@@ -237,12 +236,12 @@ class CreateController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function duplicate(Request $request): JsonResponse
|
||||
{
|
||||
$ruleId = (int) $request->get('id');
|
||||
$ruleId = (int)$request->get('id');
|
||||
$rule = $this->ruleRepos->find($ruleId);
|
||||
if (null !== $rule) {
|
||||
$this->ruleRepos->duplicate($rule);
|
||||
@@ -254,7 +253,7 @@ class CreateController extends Controller
|
||||
/**
|
||||
* Store the new rule.
|
||||
*
|
||||
* @param RuleFormRequest $request
|
||||
* @param RuleFormRequest $request
|
||||
*
|
||||
* @return RedirectResponse|Redirector
|
||||
*
|
||||
@@ -264,22 +263,22 @@ class CreateController extends Controller
|
||||
$data = $request->getRuleData();
|
||||
|
||||
$rule = $this->ruleRepos->store($data);
|
||||
session()->flash('success', (string) trans('firefly.stored_new_rule', ['title' => $rule->title]));
|
||||
session()->flash('success', (string)trans('firefly.stored_new_rule', ['title' => $rule->title]));
|
||||
app('preferences')->mark();
|
||||
|
||||
// redirect to show bill.
|
||||
if ('true' === $request->get('return_to_bill') && (int) $request->get('bill_id') > 0) {
|
||||
return redirect(route('bills.show', [(int) $request->get('bill_id')]));
|
||||
if ('true' === $request->get('return_to_bill') && (int)$request->get('bill_id') > 0) {
|
||||
return redirect(route('bills.show', [(int)$request->get('bill_id')]));
|
||||
}
|
||||
|
||||
// redirect to new bill creation.
|
||||
if ((int) $request->get('bill_id') > 0) {
|
||||
if ((int)$request->get('bill_id') > 0) {
|
||||
return redirect($this->getPreviousUrl('bills.create.url'));
|
||||
}
|
||||
|
||||
$redirect = redirect($this->getPreviousUrl('rules.create.url'));
|
||||
|
||||
if (1 === (int) $request->get('create_another')) {
|
||||
if (1 === (int)$request->get('create_another')) {
|
||||
session()->put('rules.create.fromStore', true);
|
||||
$redirect = redirect(route('rules.create', [$data['rule_group_id']]))->withInput();
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ class DeleteController extends Controller
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string) trans('firefly.rules'));
|
||||
app('view')->share('title', (string)trans('firefly.rules'));
|
||||
app('view')->share('mainTitleIcon', 'fa-random');
|
||||
|
||||
$this->ruleRepos = app(RuleRepositoryInterface::class);
|
||||
@@ -62,13 +62,13 @@ class DeleteController extends Controller
|
||||
/**
|
||||
* Delete a given rule.
|
||||
*
|
||||
* @param Rule $rule
|
||||
* @param Rule $rule
|
||||
*
|
||||
* @return Factory|View
|
||||
*/
|
||||
public function delete(Rule $rule)
|
||||
{
|
||||
$subTitle = (string) trans('firefly.delete_rule', ['title' => $rule->title]);
|
||||
$subTitle = (string)trans('firefly.delete_rule', ['title' => $rule->title]);
|
||||
|
||||
// put previous url in session
|
||||
$this->rememberPreviousUrl('rules.delete.url');
|
||||
@@ -79,7 +79,7 @@ class DeleteController extends Controller
|
||||
/**
|
||||
* Actually destroy the given rule.
|
||||
*
|
||||
* @param Rule $rule
|
||||
* @param Rule $rule
|
||||
*
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
@@ -88,7 +88,7 @@ class DeleteController extends Controller
|
||||
$title = $rule->title;
|
||||
$this->ruleRepos->destroy($rule);
|
||||
|
||||
session()->flash('success', (string) trans('firefly.deleted_rule', ['title' => $title]));
|
||||
session()->flash('success', (string)trans('firefly.deleted_rule', ['title' => $title]));
|
||||
app('preferences')->mark();
|
||||
|
||||
return redirect($this->getPreviousUrl('rules.delete.url'));
|
||||
|
||||
@@ -61,7 +61,7 @@ class EditController extends Controller
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string) trans('firefly.rules'));
|
||||
app('view')->share('title', (string)trans('firefly.rules'));
|
||||
app('view')->share('mainTitleIcon', 'fa-random');
|
||||
|
||||
$this->ruleRepos = app(RuleRepositoryInterface::class);
|
||||
@@ -74,8 +74,8 @@ class EditController extends Controller
|
||||
/**
|
||||
* Edit a rule.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Rule $rule
|
||||
* @param Request $request
|
||||
* @param Rule $rule
|
||||
*
|
||||
* @return Factory|View
|
||||
*/
|
||||
@@ -87,7 +87,7 @@ class EditController extends Controller
|
||||
$oldTriggers = [];
|
||||
|
||||
// build triggers from query, if present.
|
||||
$query = (string) $request->get('from_query');
|
||||
$query = (string)$request->get('from_query');
|
||||
if ('' !== $query) {
|
||||
$search = app(SearchInterface::class);
|
||||
$search->parseQuery($query);
|
||||
@@ -117,15 +117,15 @@ class EditController extends Controller
|
||||
|
||||
$hasOldInput = null !== $request->old('_token');
|
||||
$preFilled = [
|
||||
'active' => $hasOldInput ? (bool) $request->old('active') : $rule->active,
|
||||
'stop_processing' => $hasOldInput ? (bool) $request->old('stop_processing') : $rule->stop_processing,
|
||||
'strict' => $hasOldInput ? (bool) $request->old('strict') : $rule->strict,
|
||||
'active' => $hasOldInput ? (bool)$request->old('active') : $rule->active,
|
||||
'stop_processing' => $hasOldInput ? (bool)$request->old('stop_processing') : $rule->stop_processing,
|
||||
'strict' => $hasOldInput ? (bool)$request->old('strict') : $rule->strict,
|
||||
|
||||
];
|
||||
|
||||
// get rule trigger for update / store-journal:
|
||||
$primaryTrigger = $this->ruleRepos->getPrimaryTrigger($rule);
|
||||
$subTitle = (string) trans('firefly.edit_rule', ['title' => $rule->title]);
|
||||
$subTitle = (string)trans('firefly.edit_rule', ['title' => $rule->title]);
|
||||
|
||||
// put previous url in session if not redirect from store (not "return_to_edit").
|
||||
if (true !== session('rules.edit.fromUpdate')) {
|
||||
@@ -139,7 +139,7 @@ class EditController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $submittedOperators
|
||||
* @param array $submittedOperators
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -151,7 +151,7 @@ class EditController extends Controller
|
||||
$triggers = [];
|
||||
foreach ($operators as $key => $operator) {
|
||||
if ('user_action' !== $key && false === $operator['alias']) {
|
||||
$triggers[$key] = (string) trans(sprintf('firefly.rule_trigger_%s_choice', $key));
|
||||
$triggers[$key] = (string)trans(sprintf('firefly.rule_trigger_%s_choice', $key));
|
||||
}
|
||||
}
|
||||
asort($triggers);
|
||||
@@ -183,8 +183,8 @@ class EditController extends Controller
|
||||
/**
|
||||
* Update the rule.
|
||||
*
|
||||
* @param RuleFormRequest $request
|
||||
* @param Rule $rule
|
||||
* @param RuleFormRequest $request
|
||||
* @param Rule $rule
|
||||
*
|
||||
* @return RedirectResponse|Redirector
|
||||
*/
|
||||
@@ -194,10 +194,10 @@ class EditController extends Controller
|
||||
|
||||
$this->ruleRepos->update($rule, $data);
|
||||
|
||||
session()->flash('success', (string) trans('firefly.updated_rule', ['title' => $rule->title]));
|
||||
session()->flash('success', (string)trans('firefly.updated_rule', ['title' => $rule->title]));
|
||||
app('preferences')->mark();
|
||||
$redirect = redirect($this->getPreviousUrl('rules.edit.url'));
|
||||
if (1 === (int) $request->get('return_to_edit')) {
|
||||
if (1 === (int)$request->get('return_to_edit')) {
|
||||
session()->put('rules.edit.fromUpdate', true);
|
||||
|
||||
$redirect = redirect(route('rules.edit', [$rule->id]))->withInput(['return_to_edit' => 1]);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* IndexController.php
|
||||
* Copyright (c) 2019 james@firefly-iii.org
|
||||
@@ -54,7 +55,7 @@ class IndexController extends Controller
|
||||
parent::__construct();
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string) trans('firefly.rules'));
|
||||
app('view')->share('title', (string)trans('firefly.rules'));
|
||||
app('view')->share('mainTitleIcon', 'fa-random');
|
||||
$this->ruleGroupRepos = app(RuleGroupRepositoryInterface::class);
|
||||
$this->ruleRepos = app(RuleRepositoryInterface::class);
|
||||
@@ -79,22 +80,22 @@ class IndexController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param Rule $rule
|
||||
* @param RuleGroup $ruleGroup
|
||||
* @param Request $request
|
||||
* @param Rule $rule
|
||||
* @param RuleGroup $ruleGroup
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function moveRule(Request $request, Rule $rule, RuleGroup $ruleGroup): JsonResponse
|
||||
{
|
||||
$order = (int) $request->get('order');
|
||||
$this->ruleRepos->moveRule($rule, $ruleGroup, (int) $order);
|
||||
$order = (int)$request->get('order');
|
||||
$this->ruleRepos->moveRule($rule, $ruleGroup, (int)$order);
|
||||
|
||||
return response()->json([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Rule $rule
|
||||
* @param Rule $rule
|
||||
*
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
|
||||
@@ -59,7 +59,7 @@ class SelectController extends Controller
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string) trans('firefly.rules'));
|
||||
app('view')->share('title', (string)trans('firefly.rules'));
|
||||
app('view')->share('mainTitleIcon', 'fa-random');
|
||||
|
||||
return $next($request);
|
||||
@@ -70,8 +70,8 @@ class SelectController extends Controller
|
||||
/**
|
||||
* Execute the given rule on a set of existing transactions.
|
||||
*
|
||||
* @param SelectTransactionsRequest $request
|
||||
* @param Rule $rule
|
||||
* @param SelectTransactionsRequest $request
|
||||
* @param Rule $rule
|
||||
*
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
@@ -98,7 +98,7 @@ class SelectController extends Controller
|
||||
$newRuleEngine->fire();
|
||||
$resultCount = $newRuleEngine->getResults();
|
||||
|
||||
session()->flash('success', (string) trans_choice('firefly.applied_rule_selection', $resultCount, ['title' => $rule->title]));
|
||||
session()->flash('success', (string)trans_choice('firefly.applied_rule_selection', $resultCount, ['title' => $rule->title]));
|
||||
|
||||
return redirect()->route('rules.index');
|
||||
}
|
||||
@@ -106,7 +106,7 @@ class SelectController extends Controller
|
||||
/**
|
||||
* View to select transactions by a rule.
|
||||
*
|
||||
* @param Rule $rule
|
||||
* @param Rule $rule
|
||||
*
|
||||
* @return Factory|View
|
||||
*/
|
||||
@@ -120,7 +120,7 @@ class SelectController extends Controller
|
||||
// does the user have shared accounts?
|
||||
$first = session('first', Carbon::now()->subYear())->format('Y-m-d');
|
||||
$today = Carbon::now()->format('Y-m-d');
|
||||
$subTitle = (string) trans('firefly.apply_rule_selection', ['title' => $rule->title]);
|
||||
$subTitle = (string)trans('firefly.apply_rule_selection', ['title' => $rule->title]);
|
||||
|
||||
return view('rules.rule.select-transactions', compact('first', 'today', 'rule', 'subTitle'));
|
||||
}
|
||||
@@ -129,7 +129,7 @@ class SelectController extends Controller
|
||||
* This method allows the user to test a certain set of rule triggers. The rule triggers are passed along
|
||||
* using the URL parameters (GET), and are usually put there using a Javascript thing.
|
||||
*
|
||||
* @param TestRuleFormRequest $request
|
||||
* @param TestRuleFormRequest $request
|
||||
*
|
||||
* @return JsonResponse
|
||||
*
|
||||
@@ -146,7 +146,7 @@ class SelectController extends Controller
|
||||
|
||||
// warn if nothing.
|
||||
if (0 === count($textTriggers)) {
|
||||
return response()->json(['html' => '', 'warning' => (string) trans('firefly.warning_no_valid_triggers')]);
|
||||
return response()->json(['html' => '', 'warning' => (string)trans('firefly.warning_no_valid_triggers')]);
|
||||
}
|
||||
|
||||
foreach ($textTriggers as $textTrigger) {
|
||||
@@ -170,7 +170,7 @@ class SelectController extends Controller
|
||||
// Warn the user if only a subset of transactions is returned
|
||||
$warning = '';
|
||||
if (0 === count($collection)) {
|
||||
$warning = (string) trans('firefly.warning_no_matching_transactions');
|
||||
$warning = (string)trans('firefly.warning_no_matching_transactions');
|
||||
}
|
||||
|
||||
// Return json response
|
||||
@@ -191,7 +191,7 @@ class SelectController extends Controller
|
||||
* This method allows the user to test a certain set of rule triggers. The rule triggers are grabbed from
|
||||
* the rule itself.
|
||||
*
|
||||
* @param Rule $rule
|
||||
* @param Rule $rule
|
||||
*
|
||||
* @return JsonResponse
|
||||
*
|
||||
@@ -201,7 +201,7 @@ class SelectController extends Controller
|
||||
$triggers = $rule->ruleTriggers;
|
||||
|
||||
if (0 === count($triggers)) {
|
||||
return response()->json(['html' => '', 'warning' => (string) trans('firefly.warning_no_valid_triggers')]);
|
||||
return response()->json(['html' => '', 'warning' => (string)trans('firefly.warning_no_valid_triggers')]);
|
||||
}
|
||||
// create new rule engine:
|
||||
$newRuleEngine = app(RuleEngineInterface::class);
|
||||
@@ -213,7 +213,7 @@ class SelectController extends Controller
|
||||
|
||||
$warning = '';
|
||||
if (0 === count($collection)) {
|
||||
$warning = (string) trans('firefly.warning_no_matching_transactions');
|
||||
$warning = (string)trans('firefly.warning_no_matching_transactions');
|
||||
}
|
||||
|
||||
// Return json response
|
||||
|
||||
Reference in New Issue
Block a user