Various code cleanup.

This commit is contained in:
James Cole
2022-12-30 09:28:03 +01:00
parent 03e176bd16
commit ee0116f112
17 changed files with 171 additions and 125 deletions

View File

@@ -34,6 +34,9 @@ use FireflyIII\User;
use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Storage;
use League\Flysystem\UnableToDeleteFile;
use LogicException;
use Log;
/**
* Class AttachmentRepository.
@@ -58,7 +61,7 @@ class AttachmentRepository implements AttachmentRepositoryInterface
$path = $helper->getAttachmentLocation($attachment);
try {
Storage::disk('upload')->delete($path);
} catch (Exception $e) {
} catch (UnableToDeleteFile $e) {
// @ignoreException
}
$attachment->delete();
@@ -161,7 +164,6 @@ class AttachmentRepository implements AttachmentRepositoryInterface
* @param array $data
*
* @return Attachment
* @throws Exception
*/
public function update(Attachment $attachment, array $data): Attachment
{
@@ -193,7 +195,6 @@ class AttachmentRepository implements AttachmentRepositoryInterface
* @param string $note
*
* @return bool
* @throws Exception
*/
public function updateNote(Attachment $attachment, string $note): bool
{
@@ -202,8 +203,8 @@ class AttachmentRepository implements AttachmentRepositoryInterface
if (null !== $dbNote) {
try {
$dbNote->delete();
} catch (Exception $e) {
// @ignoreException
} catch (LogicException $e) {
Log::error($e->getMessage());
}
}

View File

@@ -383,6 +383,8 @@ class BillRepository implements BillRepositoryInterface
}
/**
* TODO unsure why this is deprecated.
*
* Get the total amount of money paid for the users active bills in the date range given.
* This amount will be negative (they're expenses). This method is equal to
* getBillsUnpaidInRange. So the debug comments are gone.
@@ -412,6 +414,8 @@ class BillRepository implements BillRepositoryInterface
}
/**
* TODO unsure why this is deprecated.
*
* Get the total amount of money paid for the users active bills in the date range given,
* grouped per currency.
* @param Carbon $start
@@ -442,6 +446,8 @@ class BillRepository implements BillRepositoryInterface
}
/**
* TODO unsure why this is deprecated.
*
* Get the total amount of money due for the users active bills in the date range given. This amount will be positive.
*
* @param Carbon $start
@@ -474,6 +480,8 @@ class BillRepository implements BillRepositoryInterface
}
/**
* TODO unsure why this is deprecated.
*
* Get the total amount of money due for the users active bills in the date range given.
*
* @param Carbon $start

View File

@@ -24,7 +24,6 @@ declare(strict_types=1);
namespace FireflyIII\Repositories\Budget;
use Carbon\Carbon;
use Exception;
use FireflyIII\Models\AvailableBudget;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\User;
@@ -52,11 +51,7 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface
*/
public function destroyAvailableBudget(AvailableBudget $availableBudget): void
{
try {
$availableBudget->delete();
} catch (Exception $e) {
// @ignoreException
}
$availableBudget->delete();
}
/**

View File

@@ -89,6 +89,7 @@ interface OperationsRepositoryInterface
public function spentInPeriodMc(Collection $budgets, Collection $accounts, Carbon $start, Carbon $end): array;
/**
* TODO this method was marked as deprecated but I'm not sure why.
* @param Carbon $start
* @param Carbon $end
* @param Collection|null $accounts
@@ -96,7 +97,7 @@ interface OperationsRepositoryInterface
* @param TransactionCurrency|null $currency
*
* @return array
* @deprecated
*
*/
public function sumExpenses(
Carbon $start,