mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-01-06 22:21:42 +00:00
Various code cleanup.
This commit is contained in:
@@ -417,7 +417,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
*
|
||||
* @param Account $account
|
||||
*
|
||||
* @return string
|
||||
* @return string|null
|
||||
*/
|
||||
public function getOpeningBalanceAmount(Account $account): ?string
|
||||
{
|
||||
@@ -748,7 +748,6 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
* @param array $data
|
||||
*
|
||||
* @return Account
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function update(Account $account, array $data): Account
|
||||
{
|
||||
|
||||
@@ -195,7 +195,7 @@ interface AccountRepositoryInterface
|
||||
*
|
||||
* @param Account $account
|
||||
*
|
||||
* @return string
|
||||
* @return string|null
|
||||
*/
|
||||
public function getOpeningBalanceAmount(Account $account): ?string;
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ class AttachmentRepository implements AttachmentRepositoryInterface
|
||||
*
|
||||
* @param Attachment $attachment
|
||||
*
|
||||
* @return string
|
||||
* @return string|null
|
||||
*/
|
||||
public function getNoteText(Attachment $attachment): ?string
|
||||
{
|
||||
@@ -167,6 +167,7 @@ class AttachmentRepository implements AttachmentRepositoryInterface
|
||||
* @param array $data
|
||||
*
|
||||
* @return Attachment
|
||||
* @throws Exception
|
||||
*/
|
||||
public function update(Attachment $attachment, array $data): Attachment
|
||||
{
|
||||
|
||||
@@ -64,7 +64,7 @@ interface AttachmentRepositoryInterface
|
||||
*
|
||||
* @param Attachment $attachment
|
||||
*
|
||||
* @return string
|
||||
* @return string|null
|
||||
*/
|
||||
public function getNoteText(Attachment $attachment): ?string;
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ class BillRepository implements BillRepositoryInterface
|
||||
*
|
||||
* @param int $billId
|
||||
*
|
||||
* @return Bill
|
||||
* @return Bill|null
|
||||
*/
|
||||
public function find(int $billId): ?Bill
|
||||
{
|
||||
@@ -142,7 +142,7 @@ class BillRepository implements BillRepositoryInterface
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return Bill
|
||||
* @return Bill|null
|
||||
*/
|
||||
public function findByName(string $name): ?Bill
|
||||
{
|
||||
|
||||
@@ -146,11 +146,10 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Carbon|null $start
|
||||
* @param Carbon|null $end
|
||||
*
|
||||
* @return Collection
|
||||
*
|
||||
*/
|
||||
public function getAllBudgetLimits(Carbon $start = null, Carbon $end = null): Collection
|
||||
{
|
||||
@@ -216,8 +215,8 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface
|
||||
|
||||
/**
|
||||
* @param TransactionCurrency $currency
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Carbon|null $start
|
||||
* @param Carbon|null $end
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
@@ -231,12 +230,11 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Budget $budget
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Budget $budget
|
||||
* @param Carbon|null $start
|
||||
* @param Carbon|null $end
|
||||
*
|
||||
* @return Collection
|
||||
*
|
||||
*/
|
||||
public function getBudgetLimits(Budget $budget, Carbon $start = null, Carbon $end = null): Collection
|
||||
{
|
||||
|
||||
@@ -74,8 +74,8 @@ interface BudgetLimitRepositoryInterface
|
||||
/**
|
||||
* TODO this method is not multi-currency aware.
|
||||
*
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Carbon|null $start
|
||||
* @param Carbon|null $end
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
@@ -83,17 +83,17 @@ interface BudgetLimitRepositoryInterface
|
||||
|
||||
/**
|
||||
* @param TransactionCurrency $currency
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Carbon|null $start
|
||||
* @param Carbon|null $end
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getAllBudgetLimitsByCurrency(TransactionCurrency $currency, Carbon $start = null, Carbon $end = null): Collection;
|
||||
|
||||
/**
|
||||
* @param Budget $budget
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Budget $budget
|
||||
* @param Carbon|null $start
|
||||
* @param Carbon|null $end
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
|
||||
@@ -160,7 +160,7 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
/**
|
||||
* Find a budget or return NULL
|
||||
*
|
||||
* @param int $budgetId |null
|
||||
* @param int|null $budgetId |null
|
||||
*
|
||||
* @return Budget|null
|
||||
*/
|
||||
@@ -179,8 +179,7 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
*
|
||||
* @param Budget $budget
|
||||
*
|
||||
* @return Carbon
|
||||
*
|
||||
* @return Carbon|null
|
||||
*/
|
||||
public function firstUseDate(Budget $budget): ?Carbon
|
||||
{
|
||||
|
||||
@@ -88,7 +88,7 @@ interface BudgetRepositoryInterface
|
||||
*
|
||||
* @param Budget $budget
|
||||
*
|
||||
* @return Carbon
|
||||
* @return Carbon|null
|
||||
*/
|
||||
public function firstUseDate(Budget $budget): ?Carbon;
|
||||
|
||||
|
||||
@@ -105,6 +105,7 @@ class CategoryRepository implements CategoryRepositoryInterface
|
||||
* @param string|null $categoryName
|
||||
*
|
||||
* @return Category|null
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function findCategory(?int $categoryId, ?string $categoryName): ?Category
|
||||
{
|
||||
@@ -228,7 +229,7 @@ class CategoryRepository implements CategoryRepositoryInterface
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return Carbon|null
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function lastUseDate(Category $category, Collection $accounts): ?Carbon
|
||||
{
|
||||
|
||||
@@ -51,7 +51,7 @@ interface CategoryRepositoryInterface
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return Category
|
||||
* @return Category|null
|
||||
*/
|
||||
public function findByName(string $name): ?Category;
|
||||
|
||||
|
||||
@@ -78,6 +78,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
||||
* @param TransactionCurrency $currency
|
||||
*
|
||||
* @return string|null
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function currencyInUseAt(TransactionCurrency $currency): ?string
|
||||
{
|
||||
@@ -244,7 +245,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
||||
*
|
||||
* @param string $currencyName
|
||||
*
|
||||
* @return TransactionCurrency
|
||||
* @return TransactionCurrency|null
|
||||
*/
|
||||
public function findByName(string $currencyName): ?TransactionCurrency
|
||||
{
|
||||
@@ -257,7 +258,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
||||
*
|
||||
* @param string $currencyName
|
||||
*
|
||||
* @return TransactionCurrency
|
||||
* @return TransactionCurrency|null
|
||||
* @deprecated
|
||||
*/
|
||||
public function findByNameNull(string $currencyName): ?TransactionCurrency
|
||||
@@ -270,7 +271,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
||||
*
|
||||
* @param string $currencySymbol
|
||||
*
|
||||
* @return TransactionCurrency
|
||||
* @return TransactionCurrency|null
|
||||
*/
|
||||
public function findBySymbol(string $currencySymbol): ?TransactionCurrency
|
||||
{
|
||||
@@ -283,7 +284,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
||||
*
|
||||
* @param string $currencySymbol
|
||||
*
|
||||
* @return TransactionCurrency
|
||||
* @return TransactionCurrency|null
|
||||
* @deprecated
|
||||
*/
|
||||
public function findBySymbolNull(string $currencySymbol): ?TransactionCurrency
|
||||
|
||||
@@ -112,7 +112,7 @@ interface CurrencyRepositoryInterface
|
||||
*
|
||||
* @param string $currencyName
|
||||
*
|
||||
* @return TransactionCurrency
|
||||
* @return TransactionCurrency|null
|
||||
*/
|
||||
public function findByName(string $currencyName): ?TransactionCurrency;
|
||||
|
||||
@@ -121,7 +121,7 @@ interface CurrencyRepositoryInterface
|
||||
*
|
||||
* @param string $currencyName
|
||||
*
|
||||
* @return TransactionCurrency
|
||||
* @return TransactionCurrency|null
|
||||
*/
|
||||
public function findByNameNull(string $currencyName): ?TransactionCurrency;
|
||||
|
||||
@@ -130,7 +130,7 @@ interface CurrencyRepositoryInterface
|
||||
*
|
||||
* @param string $currencySymbol
|
||||
*
|
||||
* @return TransactionCurrency
|
||||
* @return TransactionCurrency|null
|
||||
*/
|
||||
public function findBySymbol(string $currencySymbol): ?TransactionCurrency;
|
||||
|
||||
@@ -139,7 +139,7 @@ interface CurrencyRepositoryInterface
|
||||
*
|
||||
* @param string $currencySymbol
|
||||
*
|
||||
* @return TransactionCurrency
|
||||
* @return TransactionCurrency|null
|
||||
*/
|
||||
public function findBySymbolNull(string $currencySymbol): ?TransactionCurrency;
|
||||
|
||||
|
||||
@@ -97,7 +97,6 @@ class JournalAPIRepository implements JournalAPIRepositoryInterface
|
||||
*/
|
||||
public function getPiggyBankEvents(TransactionJournal $journal): Collection
|
||||
{
|
||||
/** @var Collection $events */
|
||||
$events = $journal->piggyBankEvents()->get();
|
||||
$events->each(
|
||||
function (PiggyBankEvent $event) {
|
||||
|
||||
@@ -53,11 +53,10 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param LinkType $linkType
|
||||
* @param LinkType $moveTo
|
||||
* @param LinkType $linkType
|
||||
* @param LinkType|null $moveTo
|
||||
*
|
||||
* @return bool
|
||||
* @throws Exception
|
||||
*/
|
||||
public function destroy(LinkType $linkType, LinkType $moveTo = null): bool
|
||||
{
|
||||
@@ -244,7 +243,7 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface
|
||||
* @param TransactionJournal $outward
|
||||
*
|
||||
* @return TransactionJournalLink|null
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function storeLink(array $information, TransactionJournal $inward, TransactionJournal $outward): ?TransactionJournalLink
|
||||
{
|
||||
@@ -331,10 +330,11 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface
|
||||
* @param array $data
|
||||
*
|
||||
* @return TransactionJournalLink
|
||||
* @throws Exception
|
||||
*/
|
||||
public function updateLink(TransactionJournalLink $journalLink, array $data): TransactionJournalLink
|
||||
{
|
||||
$journalLink->source_id = $data['inward_id'] ? $data['inward_id'] : $journalLink->source_id;
|
||||
$journalLink->source_id = $data['inward_id'] ?: $journalLink->source_id;
|
||||
$journalLink->destination_id = $data['outward_id'] ? $data['outward_id'] : $journalLink->destination_id;
|
||||
$journalLink->save();
|
||||
if (array_key_exists('link_type_name', $data)) {
|
||||
@@ -346,7 +346,7 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface
|
||||
$journalLink->refresh();
|
||||
}
|
||||
|
||||
$journalLink->link_type_id = $data['link_type_id'] ? $data['link_type_id'] : $journalLink->link_type_id;
|
||||
$journalLink->link_type_id = $data['link_type_id'] ?: $journalLink->link_type_id;
|
||||
$journalLink->save();
|
||||
if (array_key_exists('notes', $data) && null !== $data['notes']) {
|
||||
$this->setNoteText($journalLink, $data['notes']);
|
||||
@@ -386,9 +386,6 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getLink(TransactionJournal $one, TransactionJournal $two): ?TransactionJournalLink
|
||||
{
|
||||
$left = TransactionJournalLink::whereDestinationId($one->id)->whereSourceId($two->id)->first();
|
||||
|
||||
@@ -41,8 +41,8 @@ interface LinkTypeRepositoryInterface
|
||||
public function countJournals(LinkType $linkType): int;
|
||||
|
||||
/**
|
||||
* @param LinkType $linkType
|
||||
* @param LinkType $moveTo
|
||||
* @param LinkType $linkType
|
||||
* @param LinkType|null $moveTo
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
|
||||
@@ -161,7 +161,7 @@ class ObjectGroupRepository implements ObjectGroupRepositoryInterface
|
||||
if ($newOrder > $oldOrder) {
|
||||
$this->user->objectGroups()->where('object_groups.order', '<=', $newOrder)->where('object_groups.order', '>', $oldOrder)
|
||||
->where('object_groups.id', '!=', $objectGroup->id)
|
||||
->decrement('object_groups.order', 1);
|
||||
->decrement('object_groups.order');
|
||||
|
||||
$objectGroup->order = $newOrder;
|
||||
$objectGroup->save();
|
||||
@@ -169,7 +169,7 @@ class ObjectGroupRepository implements ObjectGroupRepositoryInterface
|
||||
if ($newOrder < $oldOrder) {
|
||||
$this->user->objectGroups()->where('object_groups.order', '>=', $newOrder)->where('object_groups.order', '<', $oldOrder)
|
||||
->where('object_groups.id', '!=', $objectGroup->id)
|
||||
->increment('object_groups.order', 1);
|
||||
->increment('object_groups.order');
|
||||
|
||||
$objectGroup->order = $newOrder;
|
||||
$objectGroup->save();
|
||||
|
||||
@@ -290,6 +290,7 @@ class RecurringRepository implements RecurringRepositoryInterface
|
||||
* @param RecurrenceTransaction $transaction
|
||||
*
|
||||
* @return array
|
||||
* @throws \JsonException
|
||||
*/
|
||||
public function getTags(RecurrenceTransaction $transaction): array
|
||||
{
|
||||
@@ -416,7 +417,6 @@ class RecurringRepository implements RecurringRepositoryInterface
|
||||
* @param int $count
|
||||
*
|
||||
* @return array
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function getXOccurrencesSince(RecurrenceRepetition $repetition, Carbon $date, Carbon $afterDate, int $count): array
|
||||
{
|
||||
@@ -454,7 +454,7 @@ class RecurringRepository implements RecurringRepositoryInterface
|
||||
* @param RecurrenceRepetition $repetition
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function repetitionDescription(RecurrenceRepetition $repetition): string
|
||||
{
|
||||
|
||||
@@ -327,7 +327,7 @@ class RuleRepository implements RuleRepositoryInterface
|
||||
->where('rules.order', '<=', $newOrder)
|
||||
->where('rules.order', '>', $oldOrder)
|
||||
->where('rules.id', '!=', $rule->id)
|
||||
->decrement('rules.order', 1);
|
||||
->decrement('rules.order');
|
||||
$rule->order = $newOrder;
|
||||
Log::debug(sprintf('Order of rule #%d ("%s") is now %d', $rule->id, $rule->title, $newOrder));
|
||||
$rule->save();
|
||||
@@ -340,7 +340,7 @@ class RuleRepository implements RuleRepositoryInterface
|
||||
->where('rules.order', '>=', $newOrder)
|
||||
->where('rules.order', '<', $oldOrder)
|
||||
->where('rules.id', '!=', $rule->id)
|
||||
->increment('rules.order', 1);
|
||||
->increment('rules.order');
|
||||
$rule->order = $newOrder;
|
||||
Log::debug(sprintf('Order of rule #%d ("%s") is now %d', $rule->id, $rule->title, $newOrder));
|
||||
$rule->save();
|
||||
@@ -358,6 +358,7 @@ class RuleRepository implements RuleRepositoryInterface
|
||||
* @param array $data
|
||||
*
|
||||
* @return Rule
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function store(array $data): Rule
|
||||
{
|
||||
|
||||
@@ -414,7 +414,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
|
||||
if ($newOrder > $oldOrder) {
|
||||
$this->user->ruleGroups()->where('rule_groups.order', '<=', $newOrder)->where('rule_groups.order', '>', $oldOrder)
|
||||
->where('rule_groups.id', '!=', $ruleGroup->id)
|
||||
->decrement('order', 1);
|
||||
->decrement('order');
|
||||
$ruleGroup->order = $newOrder;
|
||||
Log::debug(sprintf('Order of group #%d ("%s") is now %d', $ruleGroup->id, $ruleGroup->title, $newOrder));
|
||||
$ruleGroup->save();
|
||||
@@ -424,7 +424,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
|
||||
|
||||
$this->user->ruleGroups()->where('rule_groups.order', '>=', $newOrder)->where('rule_groups.order', '<', $oldOrder)
|
||||
->where('rule_groups.id', '!=', $ruleGroup->id)
|
||||
->increment('order', 1);
|
||||
->increment('order');
|
||||
$ruleGroup->order = $newOrder;
|
||||
Log::debug(sprintf('Order of group #%d ("%s") is now %d', $ruleGroup->id, $ruleGroup->title, $newOrder));
|
||||
$ruleGroup->save();
|
||||
|
||||
@@ -207,6 +207,7 @@ class OperationsRepository implements OperationsRepositoryInterface
|
||||
* @param Collection|null $tags
|
||||
*
|
||||
* @return array
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function sumExpenses(Carbon $start, Carbon $end, ?Collection $accounts = null, ?Collection $tags = null): array
|
||||
{
|
||||
@@ -222,6 +223,7 @@ class OperationsRepository implements OperationsRepositoryInterface
|
||||
* @param Collection|null $tags
|
||||
*
|
||||
* @return array
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function sumIncome(Carbon $start, Carbon $end, ?Collection $accounts = null, ?Collection $tags = null): array
|
||||
{
|
||||
|
||||
@@ -250,7 +250,7 @@ class TagRepository implements TagRepositoryInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Tag
|
||||
* @return Tag|null
|
||||
*/
|
||||
public function oldestTag(): ?Tag
|
||||
{
|
||||
|
||||
@@ -79,7 +79,7 @@ interface TagRepositoryInterface
|
||||
/**
|
||||
* @param Tag $tag
|
||||
*
|
||||
* @return Carbon
|
||||
* @return Carbon|null
|
||||
*/
|
||||
public function firstUseDate(Tag $tag): ?Carbon;
|
||||
|
||||
|
||||
@@ -264,6 +264,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
|
||||
* @param TransactionGroup $group
|
||||
*
|
||||
* @return array
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function getPiggyEvents(TransactionGroup $group): array
|
||||
{
|
||||
|
||||
@@ -377,8 +377,8 @@ class UserRepository implements UserRepositoryInterface
|
||||
* @param string $newEmail
|
||||
*
|
||||
* @return bool
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
* @see changeEmail
|
||||
*
|
||||
*/
|
||||
public function updateEmail(User $user, string $newEmail): bool
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user