Code cleanup

This commit is contained in:
James Cole
2024-12-22 08:43:12 +01:00
parent 5751f7e5a3
commit 565bd87959
574 changed files with 4600 additions and 4604 deletions

View File

@@ -46,7 +46,7 @@ class JournalLinkRequest extends FormRequest
$return = [];
$linkType = $this->get('link_type');
$parts = explode('_', $linkType);
$return['link_type_id'] = (int)$parts[0];
$return['link_type_id'] = (int) $parts[0];
$return['transaction_journal_id'] = $this->convertInteger('opposing');
$return['notes'] = $this->convertString('notes');
$return['direction'] = $parts[1];

View File

@@ -64,10 +64,10 @@ class NotificationRequest extends FormRequest
public function rules(): array
{
$rules = [
'slack_webhook_url' => ['nullable', 'url', 'min:1', new IsValidSlackOrDiscordUrl()],
'ntfy_server' => ['nullable', 'url', 'min:1'],
'ntfy_user' => ['required_with:ntfy_pass,ntfy_auth', 'nullable', 'string', 'min:1'],
'ntfy_pass' => ['required_with:ntfy_user,ntfy_auth', 'nullable', 'string', 'min:1'],
'slack_webhook_url' => ['nullable', 'url', 'min:1', new IsValidSlackOrDiscordUrl()],
'ntfy_server' => ['nullable', 'url', 'min:1'],
'ntfy_user' => ['required_with:ntfy_pass,ntfy_auth', 'nullable', 'string', 'min:1'],
'ntfy_pass' => ['required_with:ntfy_user,ntfy_auth', 'nullable', 'string', 'min:1'],
];
foreach (config('notifications.notifications.owner') as $key => $info) {
$rules[sprintf('notification_%s', $key)] = 'in:0,1';

View File

@@ -311,18 +311,18 @@ class RecurrenceFormRequest extends FormRequest
$throwError = true;
if ('withdrawal' === $type) {
$throwError = false;
$sourceId = (int)$data['source_id'];
$destinationId = (int)$data['withdrawal_destination_id'];
$sourceId = (int) $data['source_id'];
$destinationId = (int) $data['withdrawal_destination_id'];
}
if ('deposit' === $type) {
$throwError = false;
$sourceId = (int)$data['deposit_source_id'];
$destinationId = (int)($data['destination_id'] ?? 0);
$sourceId = (int) $data['deposit_source_id'];
$destinationId = (int) ($data['destination_id'] ?? 0);
}
if ('transfer' === $type) {
$throwError = false;
$sourceId = (int)$data['source_id'];
$destinationId = (int)($data['destination_id'] ?? 0);
$sourceId = (int) $data['source_id'];
$destinationId = (int) ($data['destination_id'] ?? 0);
}
if (true === $throwError) {
throw new FireflyException(sprintf('Cannot handle transaction type "%s"', $this->convertString('transaction_type')));
@@ -333,7 +333,7 @@ class RecurrenceFormRequest extends FormRequest
// do something with result:
if (false === $validSource) {
$message = (string)trans('validation.generic_invalid_source');
$message = (string) trans('validation.generic_invalid_source');
$validator->errors()->add('source_id', $message);
$validator->errors()->add('deposit_source_id', $message);
@@ -344,7 +344,7 @@ class RecurrenceFormRequest extends FormRequest
$validDestination = $accountValidator->validateDestination(['id' => $destinationId]);
// do something with result:
if (false === $validDestination) {
$message = (string)trans('validation.generic_invalid_destination');
$message = (string) trans('validation.generic_invalid_destination');
$validator->errors()->add('destination_id', $message);
$validator->errors()->add('withdrawal_destination_id', $message);
}

View File

@@ -55,7 +55,7 @@ class ReportFormRequest extends FormRequest
$collection = new Collection();
if (is_array($set)) {
foreach ($set as $accountId) {
$account = $repository->find((int)$accountId);
$account = $repository->find((int) $accountId);
if (null !== $account) {
$collection->push($account);
}
@@ -76,7 +76,7 @@ class ReportFormRequest extends FormRequest
$collection = new Collection();
if (is_array($set)) {
foreach ($set as $budgetId) {
$budget = $repository->find((int)$budgetId);
$budget = $repository->find((int) $budgetId);
if (null !== $budget) {
$collection->push($budget);
}
@@ -97,7 +97,7 @@ class ReportFormRequest extends FormRequest
$collection = new Collection();
if (is_array($set)) {
foreach ($set as $categoryId) {
$category = $repository->find((int)$categoryId);
$category = $repository->find((int) $categoryId);
if (null !== $category) {
$collection->push($category);
}
@@ -118,7 +118,7 @@ class ReportFormRequest extends FormRequest
$collection = new Collection();
if (is_array($set)) {
foreach ($set as $accountId) {
$account = $repository->find((int)$accountId);
$account = $repository->find((int) $accountId);
if (null !== $account) {
$collection->push($account);
}
@@ -137,7 +137,7 @@ class ReportFormRequest extends FormRequest
{
$date = today(config('app.timezone'));
$range = $this->get('daterange');
$parts = explode(' - ', (string)$range);
$parts = explode(' - ', (string) $range);
if (2 === count($parts)) {
$string = $parts[1];
// validate as date
@@ -175,7 +175,7 @@ class ReportFormRequest extends FormRequest
{
$date = today(config('app.timezone'));
$range = $this->get('daterange');
$parts = explode(' - ', (string)$range);
$parts = explode(' - ', (string) $range);
if (2 === count($parts)) {
$string = $parts[0];
// validate as date
@@ -229,7 +229,7 @@ class ReportFormRequest extends FormRequest
continue;
}
$tag = $repository->find((int)$tagTag);
$tag = $repository->find((int) $tagTag);
if (null !== $tag) {
$collection->push($tag);
}

View File

@@ -70,8 +70,8 @@ class RuleFormRequest extends FormRequest
$set = [
'type' => $trigger['type'] ?? 'invalid',
'value' => $trigger['value'] ?? '',
'stop_processing' => 1 === (int)$stopProcessing,
'prohibited' => 1 === (int)$prohibited,
'stop_processing' => 1 === (int) $stopProcessing,
'prohibited' => 1 === (int) $prohibited,
];
$set = self::replaceAmountTrigger($set);
$return[] = $set;
@@ -116,7 +116,7 @@ class RuleFormRequest extends FormRequest
$return[] = [
'type' => $action['type'] ?? 'invalid',
'value' => $action['value'] ?? '',
'stop_processing' => 1 === (int)$stopProcessing,
'stop_processing' => 1 === (int) $stopProcessing,
];
}
}