mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-18 23:50:09 +00:00
Code cleanup
This commit is contained in:
@@ -91,10 +91,10 @@ class AccountFormRequest extends Request
|
||||
|
||||
/** @var Account $account */
|
||||
$account = $this->route()->parameter('account');
|
||||
if (!is_null($account)) {
|
||||
if (null !== $account) {
|
||||
// add rules:
|
||||
$rules['id'] = 'belongsToUser:accounts';
|
||||
$rules['name'] = 'required|min:1|uniqueAccountForUser:' . intval($this->get('id'));
|
||||
$rules['name'] = 'required|min:1|uniqueAccountForUser:' . (int)$this->get('id');
|
||||
$rules['iban'] = ['iban', 'nullable', new UniqueIban($account, $account->accountType->type)];
|
||||
}
|
||||
|
||||
|
||||
@@ -43,8 +43,8 @@ class AttachmentFormRequest extends Request
|
||||
public function getAttachmentData(): array
|
||||
{
|
||||
return [
|
||||
'title' => $this->string('title'),
|
||||
'notes' => $this->string('notes'),
|
||||
'title' => $this->string('title'),
|
||||
'notes' => $this->string('notes'),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -55,8 +55,8 @@ class AttachmentFormRequest extends Request
|
||||
{
|
||||
// fixed
|
||||
return [
|
||||
'title' => 'between:1,255|nullable',
|
||||
'notes' => 'between:1,65536|nullable',
|
||||
'title' => 'between:1,255|nullable',
|
||||
'notes' => 'between:1,65536|nullable',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,8 +58,8 @@ class BudgetFormRequest extends Request
|
||||
/** @var BudgetRepositoryInterface $repository */
|
||||
$repository = app(BudgetRepositoryInterface::class);
|
||||
$nameRule = 'required|between:1,100|uniqueObjectForUser:budgets,name';
|
||||
if (null !== $repository->findNull(intval($this->get('id')))) {
|
||||
$nameRule = 'required|between:1,100|uniqueObjectForUser:budgets,name,' . intval($this->get('id'));
|
||||
if (null !== $repository->findNull((int)$this->get('id'))) {
|
||||
$nameRule = 'required|between:1,100|uniqueObjectForUser:budgets,name,' . (int)$this->get('id');
|
||||
}
|
||||
|
||||
return [
|
||||
|
||||
@@ -40,7 +40,6 @@ class ExportFormRequest extends Request
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
|
||||
@@ -58,7 +58,7 @@ class ReportFormRequest extends Request
|
||||
$collection = new Collection;
|
||||
if (is_array($set)) {
|
||||
foreach ($set as $accountId) {
|
||||
$account = $repository->findNull(intval($accountId));
|
||||
$account = $repository->findNull((int)$accountId);
|
||||
if (null !== $account) {
|
||||
$collection->push($account);
|
||||
}
|
||||
@@ -79,7 +79,7 @@ class ReportFormRequest extends Request
|
||||
$collection = new Collection;
|
||||
if (is_array($set)) {
|
||||
foreach ($set as $budgetId) {
|
||||
$budget = $repository->findNull(intval($budgetId));
|
||||
$budget = $repository->findNull((int)$budgetId);
|
||||
if (null !== $budget) {
|
||||
$collection->push($budget);
|
||||
}
|
||||
@@ -100,7 +100,7 @@ class ReportFormRequest extends Request
|
||||
$collection = new Collection;
|
||||
if (is_array($set)) {
|
||||
foreach ($set as $categoryId) {
|
||||
$category = $repository->findNull(intval($categoryId));
|
||||
$category = $repository->findNull((int)$categoryId);
|
||||
if (null !== $category) {
|
||||
$collection->push($category);
|
||||
}
|
||||
@@ -119,7 +119,7 @@ class ReportFormRequest extends Request
|
||||
{
|
||||
$date = new Carbon;
|
||||
$range = $this->get('daterange');
|
||||
$parts = explode(' - ', strval($range));
|
||||
$parts = explode(' - ', (string)$range);
|
||||
if (2 === count($parts)) {
|
||||
try {
|
||||
$date = new Carbon($parts[1]);
|
||||
@@ -147,7 +147,7 @@ class ReportFormRequest extends Request
|
||||
$collection = new Collection;
|
||||
if (is_array($set)) {
|
||||
foreach ($set as $accountId) {
|
||||
$account = $repository->findNull(intval($accountId));
|
||||
$account = $repository->findNull((int)$accountId);
|
||||
if (null !== $account) {
|
||||
$collection->push($account);
|
||||
}
|
||||
@@ -166,7 +166,7 @@ class ReportFormRequest extends Request
|
||||
{
|
||||
$date = new Carbon;
|
||||
$range = $this->get('daterange');
|
||||
$parts = explode(' - ', strval($range));
|
||||
$parts = explode(' - ', (string)$range);
|
||||
if (2 === count($parts)) {
|
||||
try {
|
||||
$date = new Carbon($parts[0]);
|
||||
|
||||
@@ -37,7 +37,7 @@ class Request extends FormRequest
|
||||
*/
|
||||
public function boolean(string $field): bool
|
||||
{
|
||||
return 1 === intval($this->input($field));
|
||||
return 1 === (int)$this->input($field);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -47,7 +47,7 @@ class Request extends FormRequest
|
||||
*/
|
||||
public function integer(string $field): int
|
||||
{
|
||||
return intval($this->get($field));
|
||||
return (int)$this->get($field);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -73,8 +73,8 @@ class RuleFormRequest extends Request
|
||||
$contextActions = implode(',', config('firefly.rule-actions-text'));
|
||||
|
||||
$titleRule = 'required|between:1,100|uniqueObjectForUser:rules,title';
|
||||
if (null !== $repository->find(intval($this->get('id')))->id) {
|
||||
$titleRule = 'required|between:1,100|uniqueObjectForUser:rules,title,' . intval($this->get('id'));
|
||||
if (null !== $repository->find((int)$this->get('id'))->id) {
|
||||
$titleRule = 'required|between:1,100|uniqueObjectForUser:rules,title,' . (int)$this->get('id');
|
||||
}
|
||||
$rules = [
|
||||
'title' => $titleRule,
|
||||
|
||||
@@ -58,8 +58,8 @@ class RuleGroupFormRequest extends Request
|
||||
/** @var RuleGroupRepositoryInterface $repository */
|
||||
$repository = app(RuleGroupRepositoryInterface::class);
|
||||
$titleRule = 'required|between:1,100|uniqueObjectForUser:rule_groups,title';
|
||||
if (null !== $repository->find(intval($this->get('id')))->id) {
|
||||
$titleRule = 'required|between:1,100|uniqueObjectForUser:rule_groups,title,' . intval($this->get('id'));
|
||||
if (null !== $repository->find((int)$this->get('id'))->id) {
|
||||
$titleRule = 'required|between:1,100|uniqueObjectForUser:rule_groups,title,' . (int)$this->get('id');
|
||||
}
|
||||
|
||||
return [
|
||||
|
||||
@@ -41,7 +41,6 @@ class SelectTransactionsRequest extends Request
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
|
||||
@@ -77,7 +77,7 @@ class SplitJournalFormRequest extends Request
|
||||
break;
|
||||
}
|
||||
$foreignAmount = $transaction['foreign_amount'] ?? null;
|
||||
$foreignCurrencyId = intval($transaction['foreign_currency_id'] ?? 0);
|
||||
$foreignCurrencyId = (int)($transaction['foreign_currency_id'] ?? 0.0);
|
||||
$set = [
|
||||
'source_id' => $sourceId,
|
||||
'source_name' => $sourceName,
|
||||
@@ -92,7 +92,7 @@ class SplitJournalFormRequest extends Request
|
||||
'currency_code' => null,
|
||||
'description' => $transaction['transaction_description'],
|
||||
'amount' => $transaction['amount'],
|
||||
'budget_id' => intval($transaction['budget_id'] ?? 0),
|
||||
'budget_id' => (int)($transaction['budget_id'] ?? 0.0),
|
||||
'budget_name' => null,
|
||||
'category_id' => null,
|
||||
'category_name' => $transaction['category_name'],
|
||||
@@ -124,7 +124,7 @@ class SplitJournalFormRequest extends Request
|
||||
'transactions.*.destination_name' => 'between:1,255|nullable',
|
||||
'transactions.*.amount' => 'required|numeric',
|
||||
'transactions.*.budget_id' => 'belongsToUser:budgets,id',
|
||||
'transactions.*.category_name' => 'between:1,255|nullable',
|
||||
'transactions.*.category_name' => 'between:1,255|nullable',
|
||||
'transactions.*.piggy_bank_id' => 'between:1,255|nullable',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ class TagFormRequest extends Request
|
||||
$repository = app(TagRepositoryInterface::class);
|
||||
$idRule = '';
|
||||
$tagRule = 'required|min:1|uniqueObjectForUser:tags,tag';
|
||||
if (null !== $repository->find(intval($this->get('id')))->id) {
|
||||
if (null !== $repository->find((int)$this->get('id'))->id) {
|
||||
$idRule = 'belongsToUser:tags';
|
||||
$tagRule = 'required|min:1|uniqueObjectForUser:tags,tag,' . $this->get('id');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user