Code optimalisations.

This commit is contained in:
James Cole
2018-07-05 21:18:53 +02:00
parent 1675a0d442
commit c99b7e927d
26 changed files with 216 additions and 150 deletions

View File

@@ -62,14 +62,14 @@ class RuleRequest extends Request
$data['rule-triggers'][] = [
'name' => $trigger['name'],
'value' => $trigger['value'],
'stop-processing' => (int)($trigger['stop-processing'] ?? 0) === 1,
'stop-processing' => 1 === (int)($trigger['stop-processing'] ?? 0),
];
}
foreach ($this->get('rule-actions') as $action) {
$data['rule-actions'][] = [
'name' => $action['name'],
'value' => $action['value'],
'stop-processing' => (int)($action['stop-processing'] ?? 0) === 1,
'stop-processing' => 1 === (int)($action['stop-processing'] ?? 0),
];
}
@@ -134,7 +134,7 @@ class RuleRequest extends Request
$data = $validator->getData();
$repetitions = $data['rule-actions'] ?? [];
// need at least one transaction
if (\count($repetitions) === 0) {
if (0 === \count($repetitions)) {
$validator->errors()->add('title', trans('validation.at_least_one_action'));
}
}
@@ -149,7 +149,7 @@ class RuleRequest extends Request
$data = $validator->getData();
$repetitions = $data['rule-triggers'] ?? [];
// need at least one transaction
if (\count($repetitions) === 0) {
if (0 === \count($repetitions)) {
$validator->errors()->add('title', trans('validation.at_least_one_trigger'));
}
}

View File

@@ -124,7 +124,7 @@ class TransactionRequest extends Request
'transactions.*.destination_name' => 'between:1,255|nullable',
];
if ($this->method() === 'PUT') {
if ('PUT' === $this->method()) {
unset($rules['type'], $rules['piggy_bank_id'], $rules['piggy_bank_name']);
}