Clean up code.

This commit is contained in:
James Cole
2023-12-10 06:45:59 +01:00
parent 9a807fc215
commit c2b22a2bac
157 changed files with 648 additions and 669 deletions

View File

@@ -164,7 +164,7 @@ trait JournalServiceTrait
// find by preferred type.
$source = $this->accountRepository->findByIbanNull($data['iban'], [$types[0]]);
// or any expected type.
$source = $source ?? $this->accountRepository->findByIbanNull($data['iban'], $types);
$source ??= $this->accountRepository->findByIbanNull($data['iban'], $types);
if (null !== $source) {
app('log')->debug(sprintf('Found "account_iban" object: #%d, %s', $source->id, $source->name));
@@ -196,7 +196,7 @@ trait JournalServiceTrait
$source = $this->accountRepository->findByAccountNumber((string)$data['number'], [$types[0]]);
// or any expected type.
$source = $source ?? $this->accountRepository->findByAccountNumber((string)$data['number'], $types);
$source ??= $this->accountRepository->findByAccountNumber((string)$data['number'], $types);
if (null !== $source) {
app('log')->debug(sprintf('Found account: #%d, %s', $source->id, $source->name));
@@ -230,7 +230,7 @@ trait JournalServiceTrait
$source = $this->accountRepository->findByName($data['name'], [$types[0]]);
// or any expected type.
$source = $source ?? $this->accountRepository->findByName($data['name'], $types);
$source ??= $this->accountRepository->findByName($data['name'], $types);
if (null !== $source) {
app('log')->debug(sprintf('Found "account_name" object: #%d, %s', $source->id, $source->name));

View File

@@ -40,7 +40,7 @@ trait LocationServiceTrait
*/
protected function storeNewLocation(Model $model, array $data): ?Location
{
$data['store_location'] = $data['store_location'] ?? false;
$data['store_location'] ??= false;
if ($data['store_location']) {
$location = new Location();
$location->latitude = $data['latitude'] ?? config('firefly.default_location.latitude');

View File

@@ -497,9 +497,9 @@ class JournalUpdateService
{
$type = $this->transactionJournal->transactionType->type;
if ((
array_key_exists('bill_id', $this->data)
array_key_exists('bill_id', $this->data)
|| array_key_exists('bill_name', $this->data)
)
)
&& TransactionType::WITHDRAWAL === $type
) {
$billId = (int)($this->data['bill_id'] ?? 0);