mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-05 20:22:07 +00:00
Various code cleanup.
This commit is contained in:
@@ -87,7 +87,7 @@ class AccountController extends Controller
|
|||||||
$frontPage = app('preferences')->get('frontPageAccounts', $defaultSet);
|
$frontPage = app('preferences')->get('frontPageAccounts', $defaultSet);
|
||||||
$default = app('amount')->getDefaultCurrency();
|
$default = app('amount')->getDefaultCurrency();
|
||||||
|
|
||||||
if (0 === count($frontPage->data)) {
|
if (empty($frontPage->data)) {
|
||||||
$frontPage->data = $defaultSet;
|
$frontPage->data = $defaultSet;
|
||||||
$frontPage->save();
|
$frontPage->save();
|
||||||
}
|
}
|
||||||
|
@@ -109,7 +109,7 @@ class UpdateRequest extends FormRequest
|
|||||||
}
|
}
|
||||||
$return[] = $current;
|
$return[] = $current;
|
||||||
}
|
}
|
||||||
if (0 === count($return)) {
|
if (empty($return)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -167,7 +167,7 @@ class StoreRequest extends FormRequest
|
|||||||
$data = $validator->getData();
|
$data = $validator->getData();
|
||||||
$triggers = $data['triggers'] ?? [];
|
$triggers = $data['triggers'] ?? [];
|
||||||
// need at least one trigger
|
// need at least one trigger
|
||||||
if (!is_countable($triggers) || 0 === count($triggers)) {
|
if (!is_countable($triggers) || empty($triggers)) {
|
||||||
$validator->errors()->add('title', (string)trans('validation.at_least_one_trigger'));
|
$validator->errors()->add('title', (string)trans('validation.at_least_one_trigger'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -182,7 +182,7 @@ class StoreRequest extends FormRequest
|
|||||||
$data = $validator->getData();
|
$data = $validator->getData();
|
||||||
$actions = $data['actions'] ?? [];
|
$actions = $data['actions'] ?? [];
|
||||||
// need at least one trigger
|
// need at least one trigger
|
||||||
if (!is_countable($actions) || 0 === count($actions)) {
|
if (!is_countable($actions) || empty($actions)) {
|
||||||
$validator->errors()->add('title', (string)trans('validation.at_least_one_action'));
|
$validator->errors()->add('title', (string)trans('validation.at_least_one_action'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -180,7 +180,7 @@ class UpdateRequest extends FormRequest
|
|||||||
$data = $validator->getData();
|
$data = $validator->getData();
|
||||||
$triggers = $data['triggers'] ?? null;
|
$triggers = $data['triggers'] ?? null;
|
||||||
// need at least one trigger
|
// need at least one trigger
|
||||||
if (is_array($triggers) && 0 === count($triggers)) {
|
if (is_array($triggers) && empty($triggers)) {
|
||||||
$validator->errors()->add('title', (string)trans('validation.at_least_one_trigger'));
|
$validator->errors()->add('title', (string)trans('validation.at_least_one_trigger'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -195,7 +195,7 @@ class UpdateRequest extends FormRequest
|
|||||||
$data = $validator->getData();
|
$data = $validator->getData();
|
||||||
$actions = $data['actions'] ?? null;
|
$actions = $data['actions'] ?? null;
|
||||||
// need at least one action
|
// need at least one action
|
||||||
if (is_array($actions) && 0 === count($actions)) {
|
if (is_array($actions) && empty($actions)) {
|
||||||
$validator->errors()->add('title', (string)trans('validation.at_least_one_action'));
|
$validator->errors()->add('title', (string)trans('validation.at_least_one_action'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -125,11 +125,11 @@ class ExportData extends Command
|
|||||||
$exporter->setExportBills($options['export']['bills']);
|
$exporter->setExportBills($options['export']['bills']);
|
||||||
$exporter->setExportPiggies($options['export']['piggies']);
|
$exporter->setExportPiggies($options['export']['piggies']);
|
||||||
$data = $exporter->export();
|
$data = $exporter->export();
|
||||||
if (0 === count($data)) {
|
if (empty($data)) {
|
||||||
$this->error('You must export *something*. Use --export-transactions or another option. See docs.firefly-iii.org');
|
$this->error('You must export *something*. Use --export-transactions or another option. See docs.firefly-iii.org');
|
||||||
}
|
}
|
||||||
$returnCode = 0;
|
$returnCode = 0;
|
||||||
if (0 !== count($data)) {
|
if (!empty($data)) {
|
||||||
try {
|
try {
|
||||||
$this->exportData($options, $data);
|
$this->exportData($options, $data);
|
||||||
app('telemetry')->feature('system.command.executed', 'firefly-iii:export-data');
|
app('telemetry')->feature('system.command.executed', 'firefly-iii:export-data');
|
||||||
|
@@ -25,16 +25,6 @@ class VerifySecurityAlerts extends Command
|
|||||||
*/
|
*/
|
||||||
protected $description = 'Verify security alerts';
|
protected $description = 'Verify security alerts';
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new command instance.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the console command.
|
* Execute the console command.
|
||||||
*
|
*
|
||||||
|
@@ -106,7 +106,7 @@ class TransactionJournalFactory
|
|||||||
Log::debug('Start of TransactionJournalFactory::create()');
|
Log::debug('Start of TransactionJournalFactory::create()');
|
||||||
$collection = new Collection;
|
$collection = new Collection;
|
||||||
$transactions = $dataObject['transactions'] ?? [];
|
$transactions = $dataObject['transactions'] ?? [];
|
||||||
if (0 === count($transactions)) {
|
if (empty($transactions)) {
|
||||||
Log::error('There are no transactions in the array, the TransactionJournalFactory cannot continue.');
|
Log::error('There are no transactions in the array, the TransactionJournalFactory cannot continue.');
|
||||||
|
|
||||||
return new Collection;
|
return new Collection;
|
||||||
|
@@ -325,7 +325,7 @@ class GroupCollector implements GroupCollectorInterface
|
|||||||
*/
|
*/
|
||||||
public function setJournalIds(array $journalIds): GroupCollectorInterface
|
public function setJournalIds(array $journalIds): GroupCollectorInterface
|
||||||
{
|
{
|
||||||
if (0 !== count($journalIds)) {
|
if (!empty($journalIds)) {
|
||||||
// make all integers.
|
// make all integers.
|
||||||
$integerIDs = array_map('intval', $journalIds);
|
$integerIDs = array_map('intval', $journalIds);
|
||||||
|
|
||||||
|
@@ -117,7 +117,7 @@ class IndexController extends Controller
|
|||||||
$sums = $this->getSums($budgets);
|
$sums = $this->getSums($budgets);
|
||||||
|
|
||||||
// get budgeted for default currency:
|
// get budgeted for default currency:
|
||||||
if (0 === count($availableBudgets)) {
|
if (empty($availableBudgets)) {
|
||||||
$budgeted = $this->blRepository->budgeted($start, $end, $defaultCurrency,);
|
$budgeted = $this->blRepository->budgeted($start, $end, $defaultCurrency,);
|
||||||
$spentArr = $this->opsRepository->sumExpenses($start, $end, null, null, $defaultCurrency);
|
$spentArr = $this->opsRepository->sumExpenses($start, $end, null, null, $defaultCurrency);
|
||||||
$spent = $spentArr[$defaultCurrency->id]['sum'] ?? '0';
|
$spent = $spentArr[$defaultCurrency->id]['sum'] ?? '0';
|
||||||
|
@@ -331,7 +331,7 @@ class AccountController extends Controller
|
|||||||
Log::debug('Default set is ', $defaultSet);
|
Log::debug('Default set is ', $defaultSet);
|
||||||
$frontPage = app('preferences')->get('frontPageAccounts', $defaultSet);
|
$frontPage = app('preferences')->get('frontPageAccounts', $defaultSet);
|
||||||
Log::debug('Frontpage preference set is ', $frontPage->data);
|
Log::debug('Frontpage preference set is ', $frontPage->data);
|
||||||
if (0 === count($frontPage->data)) {
|
if (empty($frontPage->data)) {
|
||||||
app('preferences')->set('frontPageAccounts', $defaultSet);
|
app('preferences')->set('frontPageAccounts', $defaultSet);
|
||||||
Log::debug('frontpage set is empty!');
|
Log::debug('frontpage set is empty!');
|
||||||
}
|
}
|
||||||
|
@@ -319,7 +319,7 @@ class DoubleReportController extends Controller
|
|||||||
$journalId = $journal['transaction_journal_id'];
|
$journalId = $journal['transaction_journal_id'];
|
||||||
|
|
||||||
// no tags? also deserves a sport
|
// no tags? also deserves a sport
|
||||||
if (0 === count($journal['tags'])) {
|
if (empty($journal['tags'])) {
|
||||||
$includedJournals[] = $journalId;
|
$includedJournals[] = $journalId;
|
||||||
// do something
|
// do something
|
||||||
$tagName = trans('firefly.no_tags');
|
$tagName = trans('firefly.no_tags');
|
||||||
@@ -379,7 +379,7 @@ class DoubleReportController extends Controller
|
|||||||
$journalId = $journal['transaction_journal_id'];
|
$journalId = $journal['transaction_journal_id'];
|
||||||
|
|
||||||
// no tags? also deserves a sport
|
// no tags? also deserves a sport
|
||||||
if (0 === count($journal['tags'])) {
|
if (empty($journal['tags'])) {
|
||||||
$includedJournals[] = $journalId;
|
$includedJournals[] = $journalId;
|
||||||
// do something
|
// do something
|
||||||
$tagName = trans('firefly.no_tags');
|
$tagName = trans('firefly.no_tags');
|
||||||
|
@@ -48,7 +48,7 @@ class IntroController extends Controller
|
|||||||
$specificPage = $specificPage ?? '';
|
$specificPage = $specificPage ?? '';
|
||||||
$steps = $this->getBasicSteps($route);
|
$steps = $this->getBasicSteps($route);
|
||||||
$specificSteps = $this->getSpecificSteps($route, $specificPage);
|
$specificSteps = $this->getSpecificSteps($route, $specificPage);
|
||||||
if (0 === count($specificSteps)) {
|
if (empty($specificSteps)) {
|
||||||
Log::debug(sprintf('No specific steps for route "%s" and page "%s"', $route, $specificPage));
|
Log::debug(sprintf('No specific steps for route "%s" and page "%s"', $route, $specificPage));
|
||||||
|
|
||||||
return response()->json($steps);
|
return response()->json($steps);
|
||||||
|
@@ -115,7 +115,7 @@ class PreferencesController extends Controller
|
|||||||
$locales = ['equal' => (string)trans('firefly.equal_to_language')] + $locales;
|
$locales = ['equal' => (string)trans('firefly.equal_to_language')] + $locales;
|
||||||
// an important fallback is that the frontPageAccount array gets refilled automatically
|
// an important fallback is that the frontPageAccount array gets refilled automatically
|
||||||
// when it turns up empty.
|
// when it turns up empty.
|
||||||
if (0 === count($frontPageAccounts->data)) {
|
if (empty($frontPageAccounts->data)) {
|
||||||
$frontPageAccounts = $accountIds;
|
$frontPageAccounts = $accountIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -144,7 +144,7 @@ class SelectController extends Controller
|
|||||||
$textTriggers = $this->getValidTriggerList($request);
|
$textTriggers = $this->getValidTriggerList($request);
|
||||||
|
|
||||||
// warn if nothing.
|
// warn if nothing.
|
||||||
if (0 === count($textTriggers)) {
|
if (empty($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')]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,7 +168,7 @@ class SelectController extends Controller
|
|||||||
|
|
||||||
// Warn the user if only a subset of transactions is returned
|
// Warn the user if only a subset of transactions is returned
|
||||||
$warning = '';
|
$warning = '';
|
||||||
if (0 === count($collection)) {
|
if (empty($collection)) {
|
||||||
$warning = (string)trans('firefly.warning_no_matching_transactions');
|
$warning = (string)trans('firefly.warning_no_matching_transactions');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,7 +198,7 @@ class SelectController extends Controller
|
|||||||
{
|
{
|
||||||
$triggers = $rule->ruleTriggers;
|
$triggers = $rule->ruleTriggers;
|
||||||
|
|
||||||
if (0 === count($triggers)) {
|
if (empty($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:
|
// create new rule engine:
|
||||||
@@ -210,7 +210,7 @@ class SelectController extends Controller
|
|||||||
$collection = $collection->slice(0, 20);
|
$collection = $collection->slice(0, 20);
|
||||||
|
|
||||||
$warning = '';
|
$warning = '';
|
||||||
if (0 === count($collection)) {
|
if (empty($collection)) {
|
||||||
$warning = (string)trans('firefly.warning_no_matching_transactions');
|
$warning = (string)trans('firefly.warning_no_matching_transactions');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -88,7 +88,7 @@ class Authenticate
|
|||||||
protected function authenticate($request, array $guards)
|
protected function authenticate($request, array $guards)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (0 === count($guards)) {
|
if (empty($guards)) {
|
||||||
try {
|
try {
|
||||||
// go for default guard:
|
// go for default guard:
|
||||||
/** @noinspection PhpUndefinedMethodInspection */
|
/** @noinspection PhpUndefinedMethodInspection */
|
||||||
|
@@ -319,7 +319,7 @@ class TransactionJournal extends Model
|
|||||||
if (!self::isJoined($query, 'transaction_types')) {
|
if (!self::isJoined($query, 'transaction_types')) {
|
||||||
$query->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id');
|
$query->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id');
|
||||||
}
|
}
|
||||||
if (0 !== count($types)) {
|
if (!empty($types)) {
|
||||||
$query->whereIn('transaction_types.type', $types);
|
$query->whereIn('transaction_types.type', $types);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -125,7 +125,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
{
|
{
|
||||||
$query = $this->user->accounts()->where('iban', '!=', '')->whereNotNull('iban');
|
$query = $this->user->accounts()->where('iban', '!=', '')->whereNotNull('iban');
|
||||||
|
|
||||||
if (0 !== count($types)) {
|
if (!empty($types)) {
|
||||||
$query->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
|
$query->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
|
||||||
$query->whereIn('account_types.type', $types);
|
$query->whereIn('account_types.type', $types);
|
||||||
}
|
}
|
||||||
@@ -153,7 +153,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
{
|
{
|
||||||
$query = $this->user->accounts();
|
$query = $this->user->accounts();
|
||||||
|
|
||||||
if (0 !== count($types)) {
|
if (!empty($types)) {
|
||||||
$query->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
|
$query->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
|
||||||
$query->whereIn('account_types.type', $types);
|
$query->whereIn('account_types.type', $types);
|
||||||
}
|
}
|
||||||
@@ -222,7 +222,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
{
|
{
|
||||||
$query = $this->user->accounts();
|
$query = $this->user->accounts();
|
||||||
|
|
||||||
if (0 !== count($accountIds)) {
|
if (!empty($accountIds)) {
|
||||||
$query->whereIn('accounts.id', $accountIds);
|
$query->whereIn('accounts.id', $accountIds);
|
||||||
}
|
}
|
||||||
$query->orderBy('accounts.order', 'ASC');
|
$query->orderBy('accounts.order', 'ASC');
|
||||||
@@ -242,7 +242,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
{
|
{
|
||||||
$res = array_intersect([AccountType::ASSET, AccountType::MORTGAGE, AccountType::LOAN, AccountType::DEBT], $types);
|
$res = array_intersect([AccountType::ASSET, AccountType::MORTGAGE, AccountType::LOAN, AccountType::DEBT], $types);
|
||||||
$query = $this->user->accounts();
|
$query = $this->user->accounts();
|
||||||
if (0 !== count($types)) {
|
if (!empty($types)) {
|
||||||
$query->accountTypeIn($types);
|
$query->accountTypeIn($types);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,8 +253,8 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 === count($sort)) {
|
if (empty($sort)) {
|
||||||
if (0 !== count($res)) {
|
if (!empty($res)) {
|
||||||
$query->orderBy('accounts.order', 'ASC');
|
$query->orderBy('accounts.order', 'ASC');
|
||||||
}
|
}
|
||||||
$query->orderBy('accounts.active', 'DESC');
|
$query->orderBy('accounts.active', 'DESC');
|
||||||
@@ -276,7 +276,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
$query->where('name', 'account_role');
|
$query->where('name', 'account_role');
|
||||||
}, 'attachments']
|
}, 'attachments']
|
||||||
);
|
);
|
||||||
if (0 !== count($types)) {
|
if (!empty($types)) {
|
||||||
$query->accountTypeIn($types);
|
$query->accountTypeIn($types);
|
||||||
}
|
}
|
||||||
$query->where('active', true);
|
$query->where('active', true);
|
||||||
@@ -336,7 +336,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
$query->where('name', 'account_role');
|
$query->where('name', 'account_role');
|
||||||
}]
|
}]
|
||||||
);
|
);
|
||||||
if (0 !== count($types)) {
|
if (!empty($types)) {
|
||||||
$query->accountTypeIn($types);
|
$query->accountTypeIn($types);
|
||||||
}
|
}
|
||||||
$query->where('active', 0);
|
$query->where('active', 0);
|
||||||
@@ -674,7 +674,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if (0 !== count($types)) {
|
if (!empty($types)) {
|
||||||
$dbQuery->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
|
$dbQuery->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
|
||||||
$dbQuery->whereIn('account_types.type', $types);
|
$dbQuery->whereIn('account_types.type', $types);
|
||||||
}
|
}
|
||||||
@@ -712,7 +712,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (0 !== count($types)) {
|
if (!empty($types)) {
|
||||||
$dbQuery->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
|
$dbQuery->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
|
||||||
$dbQuery->whereIn('account_types.type', $types);
|
$dbQuery->whereIn('account_types.type', $types);
|
||||||
}
|
}
|
||||||
@@ -791,7 +791,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
if (0 !== count($types)) {
|
if (!empty($types)) {
|
||||||
$dbQuery->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
|
$dbQuery->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
|
||||||
$dbQuery->whereIn('account_types.type', $types);
|
$dbQuery->whereIn('account_types.type', $types);
|
||||||
}
|
}
|
||||||
|
@@ -355,7 +355,7 @@ class RecurringRepository implements RecurringRepositoryInterface
|
|||||||
foreach ($journalMeta as $journalId) {
|
foreach ($journalMeta as $journalId) {
|
||||||
$search[] = (int)$journalId;
|
$search[] = (int)$journalId;
|
||||||
}
|
}
|
||||||
if (0 === count($search)) {
|
if (empty($search)) {
|
||||||
|
|
||||||
return new Collection;
|
return new Collection;
|
||||||
}
|
}
|
||||||
|
@@ -67,7 +67,7 @@ class CreditRecalculateService
|
|||||||
// work based on account.
|
// work based on account.
|
||||||
$this->processAccount();
|
$this->processAccount();
|
||||||
}
|
}
|
||||||
if (0 === count($this->work)) {
|
if (empty($this->work)) {
|
||||||
Log::debug('No work accounts, do not do CreditRecalculationService');
|
Log::debug('No work accounts, do not do CreditRecalculationService');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -127,7 +127,7 @@ class CreditRecalculateService
|
|||||||
{
|
{
|
||||||
/** @var TransactionJournal $journal */
|
/** @var TransactionJournal $journal */
|
||||||
foreach ($this->group->transactionJournals as $journal) {
|
foreach ($this->group->transactionJournals as $journal) {
|
||||||
if (0 === count($this->work)) {
|
if (empty($this->work)) {
|
||||||
try {
|
try {
|
||||||
$this->findByJournal($journal);
|
$this->findByJournal($journal);
|
||||||
} catch (FireflyException $e) {
|
} catch (FireflyException $e) {
|
||||||
|
@@ -322,7 +322,7 @@ trait RecurringTransactionTrait
|
|||||||
$entry->value = json_encode($tags);
|
$entry->value = json_encode($tags);
|
||||||
$entry->save();
|
$entry->save();
|
||||||
}
|
}
|
||||||
if (0 === count($tags)) {
|
if (empty($tags)) {
|
||||||
// delete if present
|
// delete if present
|
||||||
$transaction->recurrenceTransactionMeta()->where('name', 'tags')->delete();
|
$transaction->recurrenceTransactionMeta()->where('name', 'tags')->delete();
|
||||||
}
|
}
|
||||||
|
@@ -57,7 +57,7 @@ class GroupUpdateService
|
|||||||
$transactionGroup->save();
|
$transactionGroup->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 === count($transactions)) {
|
if (empty($transactions)) {
|
||||||
Log::debug('No transactions submitted, do nothing.');
|
Log::debug('No transactions submitted, do nothing.');
|
||||||
|
|
||||||
return $transactionGroup;
|
return $transactionGroup;
|
||||||
|
@@ -149,7 +149,7 @@ class RecurrenceUpdateService
|
|||||||
private function updateRepetitions(Recurrence $recurrence, array $repetitions): void
|
private function updateRepetitions(Recurrence $recurrence, array $repetitions): void
|
||||||
{
|
{
|
||||||
$originalCount = $recurrence->recurrenceRepetitions()->count();
|
$originalCount = $recurrence->recurrenceRepetitions()->count();
|
||||||
if (0 === count($repetitions)) {
|
if (empty($repetitions)) {
|
||||||
// wont drop repetition, rather avoid.
|
// wont drop repetition, rather avoid.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -227,7 +227,7 @@ class RecurrenceUpdateService
|
|||||||
private function updateTransactions(Recurrence $recurrence, array $transactions): void
|
private function updateTransactions(Recurrence $recurrence, array $transactions): void
|
||||||
{
|
{
|
||||||
$originalCount = $recurrence->recurrenceTransactions()->count();
|
$originalCount = $recurrence->recurrenceTransactions()->count();
|
||||||
if (0 === count($transactions)) {
|
if (empty($transactions)) {
|
||||||
// wont drop transactions, rather avoid.
|
// wont drop transactions, rather avoid.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -55,7 +55,7 @@ class BudgetList implements BinderInterface
|
|||||||
$list = array_unique(array_map('\intval', explode(',', $value)));
|
$list = array_unique(array_map('\intval', explode(',', $value)));
|
||||||
|
|
||||||
|
|
||||||
if (0 === count($list)) {
|
if (empty($list)) {
|
||||||
Log::warning('Budget list count is zero, return 404.');
|
Log::warning('Budget list count is zero, return 404.');
|
||||||
throw new NotFoundHttpException;
|
throw new NotFoundHttpException;
|
||||||
}
|
}
|
||||||
|
@@ -50,7 +50,7 @@ class CategoryList implements BinderInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
$list = array_unique(array_map('\intval', explode(',', $value)));
|
$list = array_unique(array_map('\intval', explode(',', $value)));
|
||||||
if (0 === count($list)) {
|
if (empty($list)) {
|
||||||
throw new NotFoundHttpException;
|
throw new NotFoundHttpException;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -52,7 +52,7 @@ class JournalList implements BinderInterface
|
|||||||
$collector->withCategoryInformation()->withBudgetInformation()->withTagInformation()->withAccountInformation();
|
$collector->withCategoryInformation()->withBudgetInformation()->withTagInformation()->withAccountInformation();
|
||||||
$collector->setJournalIds($list);
|
$collector->setJournalIds($list);
|
||||||
$result = $collector->getExtractedJournals();
|
$result = $collector->getExtractedJournals();
|
||||||
if (0 === count($result)) {
|
if (empty($result)) {
|
||||||
throw new NotFoundHttpException;
|
throw new NotFoundHttpException;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ class JournalList implements BinderInterface
|
|||||||
protected static function parseList(string $value): array
|
protected static function parseList(string $value): array
|
||||||
{
|
{
|
||||||
$list = array_unique(array_map('\intval', explode(',', $value)));
|
$list = array_unique(array_map('\intval', explode(',', $value)));
|
||||||
if (0 === count($list)) {
|
if (empty($list)) {
|
||||||
throw new NotFoundHttpException;
|
throw new NotFoundHttpException;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -53,7 +53,7 @@ class TagList implements BinderInterface
|
|||||||
$list = array_unique(array_map('\strtolower', explode(',', $value)));
|
$list = array_unique(array_map('\strtolower', explode(',', $value)));
|
||||||
Log::debug('List of tags is', $list);
|
Log::debug('List of tags is', $list);
|
||||||
|
|
||||||
if (0 === count($list)) {
|
if (empty($list)) {
|
||||||
Log::error('Tag list is empty.');
|
Log::error('Tag list is empty.');
|
||||||
throw new NotFoundHttpException;
|
throw new NotFoundHttpException;
|
||||||
}
|
}
|
||||||
|
@@ -765,7 +765,7 @@ class ExportDataGenerator
|
|||||||
*/
|
*/
|
||||||
private function mergeTags(array $tags): string
|
private function mergeTags(array $tags): string
|
||||||
{
|
{
|
||||||
if (0 === count($tags)) {
|
if (empty($tags)) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
$smol = [];
|
$smol = [];
|
||||||
|
@@ -178,7 +178,7 @@ class OperatorQuerySearch implements SearchInterface
|
|||||||
*/
|
*/
|
||||||
public function searchTransactions(): LengthAwarePaginator
|
public function searchTransactions(): LengthAwarePaginator
|
||||||
{
|
{
|
||||||
if (0 === count($this->getWords()) && 0 === count($this->getOperators())) {
|
if (empty($this->getWords()) && empty($this->getOperators())) {
|
||||||
return new LengthAwarePaginator([], 0, 5, 1);
|
return new LengthAwarePaginator([], 0, 5, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -92,7 +92,7 @@ class ActionFactory
|
|||||||
*/
|
*/
|
||||||
protected static function getActionTypes(): array
|
protected static function getActionTypes(): array
|
||||||
{
|
{
|
||||||
if (0 === count(self::$actionTypes)) {
|
if (empty(self::$actionTypes)) {
|
||||||
self::$actionTypes = Domain::getRuleActions();
|
self::$actionTypes = Domain::getRuleActions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -126,7 +126,7 @@ trait RecurrenceValidation
|
|||||||
$data = $validator->getData();
|
$data = $validator->getData();
|
||||||
$repetitions = $data['repetitions'] ?? [];
|
$repetitions = $data['repetitions'] ?? [];
|
||||||
// need at least one transaction
|
// need at least one transaction
|
||||||
if (!is_countable($repetitions) || 0 === count($repetitions)) {
|
if (!is_countable($repetitions) || empty($repetitions)) {
|
||||||
$validator->errors()->add('repetitions', (string)trans('validation.at_least_one_repetition'));
|
$validator->errors()->add('repetitions', (string)trans('validation.at_least_one_repetition'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -144,7 +144,7 @@ trait RecurrenceValidation
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// need at least one transaction
|
// need at least one transaction
|
||||||
if (0 === count($repetitions)) {
|
if (empty($repetitions)) {
|
||||||
$validator->errors()->add('repetitions', (string)trans('validation.at_least_one_repetition'));
|
$validator->errors()->add('repetitions', (string)trans('validation.at_least_one_repetition'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -261,7 +261,7 @@ trait TransactionValidation
|
|||||||
$transactions = $this->getTransactionsArray($validator);
|
$transactions = $this->getTransactionsArray($validator);
|
||||||
|
|
||||||
// need at least one transaction
|
// need at least one transaction
|
||||||
if (0 === count($transactions)) {
|
if (empty($transactions)) {
|
||||||
$validator->errors()->add('transactions', (string)trans('validation.at_least_one_transaction'));
|
$validator->errors()->add('transactions', (string)trans('validation.at_least_one_transaction'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -276,7 +276,7 @@ trait TransactionValidation
|
|||||||
Log::debug('Now in validateOneTransaction()');
|
Log::debug('Now in validateOneTransaction()');
|
||||||
$transactions = $this->getTransactionsArray($validator);
|
$transactions = $this->getTransactionsArray($validator);
|
||||||
// need at least one transaction
|
// need at least one transaction
|
||||||
if (0 === count($transactions)) {
|
if (empty($transactions)) {
|
||||||
$validator->errors()->add('transactions.0.description', (string)trans('validation.at_least_one_transaction'));
|
$validator->errors()->add('transactions.0.description', (string)trans('validation.at_least_one_transaction'));
|
||||||
Log::debug('Added error: at_least_one_transaction.');
|
Log::debug('Added error: at_least_one_transaction.');
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user