mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Code cleanup
This commit is contained in:
@@ -65,8 +65,6 @@ class AccountDestroyService
|
||||
} catch (Exception $e) { // @codeCoverageIgnore
|
||||
Log::error(sprintf('Could not delete account: %s', $e->getMessage())); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -59,7 +59,6 @@ class JournalDestroyService
|
||||
Log::error(sprintf('Could not delete bill: %s', $e->getMessage())); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -127,6 +127,7 @@ trait AccountServiceTrait
|
||||
* @param array $data
|
||||
*
|
||||
* @return TransactionJournal|null
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
*/
|
||||
public function storeIBJournal(Account $account, array $data): ?TransactionJournal
|
||||
{
|
||||
@@ -330,7 +331,7 @@ trait AccountServiceTrait
|
||||
$entry = $account->accountMeta()->where('name', $field)->first();
|
||||
|
||||
// must not be an empty string:
|
||||
if (isset($data[$field]) && strlen((string)$data[$field]) > 0) {
|
||||
if (isset($data[$field]) && \strlen((string)$data[$field]) > 0) {
|
||||
|
||||
// if $data has field and $entry is null, create new one:
|
||||
if (null === $entry) {
|
||||
@@ -357,7 +358,7 @@ trait AccountServiceTrait
|
||||
*/
|
||||
public function updateNote(Account $account, string $note): bool
|
||||
{
|
||||
if (0 === strlen($note)) {
|
||||
if (0 === \strlen($note)) {
|
||||
$dbNote = $account->notes()->first();
|
||||
if (null !== $dbNote) {
|
||||
$dbNote->delete();
|
||||
|
||||
@@ -68,7 +68,7 @@ trait BillServiceTrait
|
||||
*/
|
||||
public function updateNote(Bill $bill, string $note): bool
|
||||
{
|
||||
if (0 === strlen($note)) {
|
||||
if (0 === \strlen($note)) {
|
||||
$dbNote = $bill->notes()->first();
|
||||
if (null !== $dbNote) {
|
||||
$dbNote->delete(); // @codeCoverageIgnore
|
||||
|
||||
@@ -47,7 +47,7 @@ trait JournalServiceTrait
|
||||
$factory = app(TagFactory::class);
|
||||
$factory->setUser($journal->user);
|
||||
$set = [];
|
||||
if (!is_array($data['tags'])) {
|
||||
if (!\is_array($data['tags'])) {
|
||||
return; // @codeCoverageIgnore
|
||||
}
|
||||
foreach ($data['tags'] as $string) {
|
||||
@@ -81,7 +81,6 @@ trait JournalServiceTrait
|
||||
$journal->bill_id = null;
|
||||
$journal->save();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -111,7 +110,7 @@ trait JournalServiceTrait
|
||||
protected function storeNote(TransactionJournal $journal, ?string $notes): void
|
||||
{
|
||||
$notes = (string)$notes;
|
||||
if (strlen($notes) > 0) {
|
||||
if (\strlen($notes) > 0) {
|
||||
$note = $journal->notes()->first();
|
||||
if (null === $note) {
|
||||
$note = new Note;
|
||||
@@ -127,7 +126,6 @@ trait JournalServiceTrait
|
||||
$note->delete();
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ trait TransactionServiceTrait
|
||||
// must be able to find it based on ID. Validator should catch invalid ID's.
|
||||
return $repository->findNull($accountId);
|
||||
}
|
||||
if (strlen($accountName) > 0) {
|
||||
if (\strlen($accountName) > 0) {
|
||||
/** @var AccountFactory $factory */
|
||||
$factory = app(AccountFactory::class);
|
||||
$factory->setUser($this->user);
|
||||
@@ -144,7 +144,7 @@ trait TransactionServiceTrait
|
||||
// must be able to find it based on ID. Validator should catch invalid ID's.
|
||||
return $repository->findNull($accountId);
|
||||
}
|
||||
if (strlen($accountName) > 0) {
|
||||
if (\strlen($accountName) > 0) {
|
||||
// alternatively, return by name.
|
||||
/** @var AccountFactory $factory */
|
||||
$factory = app(AccountFactory::class);
|
||||
@@ -222,7 +222,6 @@ trait TransactionServiceTrait
|
||||
}
|
||||
$transaction->budgets()->sync([$budget->id]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -239,7 +238,6 @@ trait TransactionServiceTrait
|
||||
}
|
||||
$transaction->categories()->sync([$category->id]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -269,7 +267,6 @@ trait TransactionServiceTrait
|
||||
$transaction->foreign_currency_id = $currency->id;
|
||||
$transaction->save();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ class AccountUpdateService
|
||||
}
|
||||
|
||||
// update note:
|
||||
if (isset($data['notes']) && null !== $data['notes']) {
|
||||
if (isset($data['notes'])) {
|
||||
$this->updateNote($account, (string)$data['notes']);
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ class JournalUpdateService
|
||||
$factory = app(TransactionFactory::class);
|
||||
$factory->setUser($journal->user);
|
||||
|
||||
Log::debug(sprintf('Found %d rows in array (should result in %d transactions', count($data['transactions']), count($data['transactions']) * 2));
|
||||
Log::debug(sprintf('Found %d rows in array (should result in %d transactions', \count($data['transactions']), \count($data['transactions']) * 2));
|
||||
|
||||
/**
|
||||
* @var int $identifier
|
||||
@@ -97,7 +97,7 @@ class JournalUpdateService
|
||||
$journal->transactions()->where('identifier', $transaction->identifier)->delete();
|
||||
}
|
||||
}
|
||||
Log::debug(sprintf('New count is %d, transactions array held %d items', $journal->transactions()->count(), count($data['transactions'])));
|
||||
Log::debug(sprintf('New count is %d, transactions array held %d items', $journal->transactions()->count(), \count($data['transactions'])));
|
||||
|
||||
// connect bill:
|
||||
$this->connectBill($journal, $data);
|
||||
|
||||
Reference in New Issue
Block a user