mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-15 16:57:09 +00:00
Code clean up.
This commit is contained in:
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Controllers;
|
||||
@@ -45,9 +44,7 @@ use Session;
|
||||
use View;
|
||||
|
||||
/**
|
||||
* Class RuleController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers
|
||||
* Class RuleController.
|
||||
*/
|
||||
class RuleController extends Controller
|
||||
{
|
||||
@@ -58,7 +55,6 @@ class RuleController extends Controller
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
View::share('title', trans('firefly.rules'));
|
||||
@@ -102,7 +98,7 @@ class RuleController extends Controller
|
||||
$subTitle = trans('firefly.make_new_rule', ['title' => $ruleGroup->title]);
|
||||
|
||||
// put previous url in session if not redirect from store (not "create another").
|
||||
if (session('rules.create.fromStore') !== true) {
|
||||
if (true !== session('rules.create.fromStore')) {
|
||||
$this->rememberPreviousUri('rules.create.uri');
|
||||
}
|
||||
Session::forget('rules.create.fromStore');
|
||||
@@ -191,7 +187,7 @@ class RuleController extends Controller
|
||||
}
|
||||
|
||||
// overrule old input when it as no rule data:
|
||||
if ($triggerCount === 0 && $actionCount === 0) {
|
||||
if (0 === $triggerCount && 0 === $actionCount) {
|
||||
$oldTriggers = $this->getCurrentTriggers($rule);
|
||||
$triggerCount = count($oldTriggers);
|
||||
$oldActions = $this->getCurrentActions($rule);
|
||||
@@ -203,7 +199,7 @@ class RuleController extends Controller
|
||||
$subTitle = trans('firefly.edit_rule', ['title' => $rule->title]);
|
||||
|
||||
// put previous url in session if not redirect from store (not "return_to_edit").
|
||||
if (session('rules.edit.fromUpdate') !== true) {
|
||||
if (true !== session('rules.edit.fromUpdate')) {
|
||||
$this->rememberPreviousUri('rules.edit.uri');
|
||||
}
|
||||
Session::forget('rules.edit.fromUpdate');
|
||||
@@ -226,13 +222,14 @@ class RuleController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the given rule on a set of existing transactions
|
||||
* Execute the given rule on a set of existing transactions.
|
||||
*
|
||||
* @param SelectTransactionsRequest $request
|
||||
* @param AccountRepositoryInterface $repository
|
||||
* @param Rule $rule
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*
|
||||
* @internal param RuleGroup $ruleGroup
|
||||
*/
|
||||
public function execute(SelectTransactionsRequest $request, AccountRepositoryInterface $repository, Rule $rule)
|
||||
@@ -343,7 +340,7 @@ class RuleController extends Controller
|
||||
Session::flash('success', trans('firefly.stored_new_rule', ['title' => $rule->title]));
|
||||
Preferences::mark();
|
||||
|
||||
if (intval($request->get('create_another')) === 1) {
|
||||
if (1 === intval($request->get('create_another'))) {
|
||||
// @codeCoverageIgnoreStart
|
||||
Session::put('rules.create.fromStore', true);
|
||||
|
||||
@@ -371,7 +368,7 @@ class RuleController extends Controller
|
||||
// build trigger array from response
|
||||
$triggers = $this->getValidTriggerList($request);
|
||||
|
||||
if (count($triggers) === 0) {
|
||||
if (0 === count($triggers)) {
|
||||
return Response::json(['html' => '', 'warning' => trans('firefly.warning_no_valid_triggers')]);
|
||||
}
|
||||
|
||||
@@ -390,7 +387,7 @@ class RuleController extends Controller
|
||||
if (count($matchingTransactions) === $limit) {
|
||||
$warning = trans('firefly.warning_transaction_subset', ['max_num_transactions' => $limit]);
|
||||
}
|
||||
if (count($matchingTransactions) === 0) {
|
||||
if (0 === count($matchingTransactions)) {
|
||||
$warning = trans('firefly.warning_no_matching_transactions', ['num_transactions' => $range]);
|
||||
}
|
||||
|
||||
@@ -417,7 +414,7 @@ class RuleController extends Controller
|
||||
{
|
||||
$triggers = $rule->ruleTriggers;
|
||||
|
||||
if (count($triggers) === 0) {
|
||||
if (0 === count($triggers)) {
|
||||
return Response::json(['html' => '', 'warning' => trans('firefly.warning_no_valid_triggers')]);
|
||||
}
|
||||
|
||||
@@ -436,7 +433,7 @@ class RuleController extends Controller
|
||||
if (count($matchingTransactions) === $limit) {
|
||||
$warning = trans('firefly.warning_transaction_subset', ['max_num_transactions' => $limit]);
|
||||
}
|
||||
if (count($matchingTransactions) === 0) {
|
||||
if (0 === count($matchingTransactions)) {
|
||||
$warning = trans('firefly.warning_no_matching_transactions', ['num_transactions' => $range]);
|
||||
}
|
||||
|
||||
@@ -474,7 +471,7 @@ class RuleController extends Controller
|
||||
Session::flash('success', trans('firefly.updated_rule', ['title' => $rule->title]));
|
||||
Preferences::mark();
|
||||
|
||||
if (intval($request->get('return_to_edit')) === 1) {
|
||||
if (1 === intval($request->get('return_to_edit'))) {
|
||||
// @codeCoverageIgnoreStart
|
||||
Session::put('rules.edit.fromUpdate', true);
|
||||
|
||||
@@ -490,7 +487,7 @@ class RuleController extends Controller
|
||||
/** @var RuleRepositoryInterface $repository */
|
||||
$repository = app(RuleRepositoryInterface::class);
|
||||
|
||||
if ($repository->count() === 0) {
|
||||
if (0 === $repository->count()) {
|
||||
$data = [
|
||||
'rule_group_id' => $repository->getFirstRuleGroup()->id,
|
||||
'stop_processing' => 0,
|
||||
@@ -519,11 +516,10 @@ class RuleController extends Controller
|
||||
*/
|
||||
private function createDefaultRuleGroup()
|
||||
{
|
||||
|
||||
/** @var RuleGroupRepositoryInterface $repository */
|
||||
$repository = app(RuleGroupRepositoryInterface::class);
|
||||
|
||||
if ($repository->count() === 0) {
|
||||
if (0 === $repository->count()) {
|
||||
$data = [
|
||||
'title' => trans('firefly.default_rule_group_name'),
|
||||
'description' => trans('firefly.default_rule_group_description'),
|
||||
@@ -555,7 +551,7 @@ class RuleController extends Controller
|
||||
'count' => $count,
|
||||
]
|
||||
)->render();
|
||||
$index++;
|
||||
++$index;
|
||||
}
|
||||
|
||||
return $actions;
|
||||
@@ -573,7 +569,7 @@ class RuleController extends Controller
|
||||
|
||||
/** @var RuleTrigger $entry */
|
||||
foreach ($rule->ruleTriggers as $entry) {
|
||||
if ($entry->trigger_type !== 'user_action') {
|
||||
if ('user_action' !== $entry->trigger_type) {
|
||||
$count = ($index + 1);
|
||||
$triggers[] = view(
|
||||
'rules.partials.trigger',
|
||||
@@ -584,7 +580,7 @@ class RuleController extends Controller
|
||||
'count' => $count,
|
||||
]
|
||||
)->render();
|
||||
$index++;
|
||||
++$index;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -614,7 +610,7 @@ class RuleController extends Controller
|
||||
'count' => $count,
|
||||
]
|
||||
)->render();
|
||||
$newIndex++;
|
||||
++$newIndex;
|
||||
}
|
||||
|
||||
return $actions;
|
||||
@@ -643,7 +639,7 @@ class RuleController extends Controller
|
||||
'count' => $count,
|
||||
]
|
||||
)->render();
|
||||
$newIndex++;
|
||||
++$newIndex;
|
||||
}
|
||||
|
||||
return $triggers;
|
||||
@@ -668,7 +664,7 @@ class RuleController extends Controller
|
||||
$triggers[] = [
|
||||
'type' => $triggerType,
|
||||
'value' => $data['rule-trigger-values'][$index],
|
||||
'stopProcessing' => intval($data['rule-trigger-stop'][$index]) === 1 ? true : false,
|
||||
'stopProcessing' => 1 === intval($data['rule-trigger-stop'][$index]) ? true : false,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user