Code cleanup

This commit is contained in:
James Cole
2024-12-22 08:43:12 +01:00
parent 5751f7e5a3
commit 565bd87959
574 changed files with 4600 additions and 4604 deletions

View File

@@ -81,10 +81,10 @@ class TransactionGroupTransformer extends AbstractTransformer
$first = new NullArrayObject(reset($group['transactions']));
return [
'id' => (int)$first['transaction_group_id'],
'id' => (int) $first['transaction_group_id'],
'created_at' => $first['created_at']->toAtomString(),
'updated_at' => $first['updated_at']->toAtomString(),
'user' => (string)$data['user_id'],
'user' => (string) $data['user_id'],
'group_title' => $data['title'],
'transactions' => $this->transformTransactions($data),
'links' => [
@@ -115,20 +115,20 @@ class TransactionGroupTransformer extends AbstractTransformer
$row = new NullArrayObject($transaction);
// amount:
$amount = app('steam')->positive((string)($row['amount'] ?? '0'));
$amount = app('steam')->positive((string) ($row['amount'] ?? '0'));
$foreignAmount = null;
if (null !== $row['foreign_amount'] && '' !== $row['foreign_amount'] && 0 !== bccomp('0', $row['foreign_amount'])) {
$foreignAmount = app('steam')->positive($row['foreign_amount']);
}
$metaFieldData = $this->groupRepos->getMetaFields((int)$row['transaction_journal_id'], $this->metaFields);
$metaDateData = $this->groupRepos->getMetaDateFields((int)$row['transaction_journal_id'], $this->metaDateFields);
$metaFieldData = $this->groupRepos->getMetaFields((int) $row['transaction_journal_id'], $this->metaFields);
$metaDateData = $this->groupRepos->getMetaDateFields((int) $row['transaction_journal_id'], $this->metaDateFields);
$type = $this->stringFromArray($transaction, 'transaction_type_type', TransactionType::WITHDRAWAL);
$longitude = null;
$latitude = null;
$zoomLevel = null;
$location = $this->getLocationById((int)$row['transaction_journal_id']);
$location = $this->getLocationById((int) $row['transaction_journal_id']);
if (null !== $location) {
$longitude = $location->longitude;
$latitude = $location->latitude;
@@ -136,17 +136,17 @@ class TransactionGroupTransformer extends AbstractTransformer
}
return [
'user' => (string)$row['user_id'],
'transaction_journal_id' => (string)$row['transaction_journal_id'],
'user' => (string) $row['user_id'],
'transaction_journal_id' => (string) $row['transaction_journal_id'],
'type' => strtolower($type),
'date' => $row['date']->toAtomString(),
'order' => $row['order'],
'currency_id' => (string)$row['currency_id'],
'currency_id' => (string) $row['currency_id'],
'currency_code' => $row['currency_code'],
'currency_name' => $row['currency_name'],
'currency_symbol' => $row['currency_symbol'],
'currency_decimal_places' => (int)$row['currency_decimal_places'],
'currency_decimal_places' => (int) $row['currency_decimal_places'],
'foreign_currency_id' => $this->stringFromArray($transaction, 'foreign_currency_id', null),
'foreign_currency_code' => $row['foreign_currency_code'],
@@ -158,12 +158,12 @@ class TransactionGroupTransformer extends AbstractTransformer
'description' => $row['description'],
'source_id' => (string)$row['source_account_id'],
'source_id' => (string) $row['source_account_id'],
'source_name' => $row['source_account_name'],
'source_iban' => $row['source_account_iban'],
'source_type' => $row['source_account_type'],
'destination_id' => (string)$row['destination_account_id'],
'destination_id' => (string) $row['destination_account_id'],
'destination_name' => $row['destination_account_name'],
'destination_iban' => $row['destination_account_iban'],
'destination_type' => $row['destination_account_type'],
@@ -178,8 +178,8 @@ class TransactionGroupTransformer extends AbstractTransformer
'bill_name' => $row['bill_name'],
'reconciled' => $row['reconciled'],
'notes' => $this->groupRepos->getNoteText((int)$row['transaction_journal_id']),
'tags' => $this->groupRepos->getTags((int)$row['transaction_journal_id']),
'notes' => $this->groupRepos->getNoteText((int) $row['transaction_journal_id']),
'tags' => $this->groupRepos->getTags((int) $row['transaction_journal_id']),
'internal_reference' => $metaFieldData['internal_reference'],
'external_id' => $metaFieldData['external_id'],
@@ -212,7 +212,7 @@ class TransactionGroupTransformer extends AbstractTransformer
'latitude' => $latitude,
'zoom_level' => $zoomLevel,
'has_attachments' => $this->hasAttachments((int)$row['transaction_journal_id']),
'has_attachments' => $this->hasAttachments((int) $row['transaction_journal_id']),
];
}
@@ -229,7 +229,7 @@ class TransactionGroupTransformer extends AbstractTransformer
return $default;
}
return (string)$array[$key];
return (string) $array[$key];
}
if (null !== $default) {
@@ -252,7 +252,7 @@ class TransactionGroupTransformer extends AbstractTransformer
private function integerFromArray(array $array, string $key): ?int
{
if (array_key_exists($key, $array)) {
return (int)$array[$key];
return (int) $array[$key];
}
return null;
@@ -435,7 +435,7 @@ class TransactionGroupTransformer extends AbstractTransformer
{
$result = $journal->transactions->first(
static function (Transaction $transaction) {
return (float)$transaction->amount < 0; // lame but it works.
return (float) $transaction->amount < 0; // lame but it works.
}
);
if (null === $result) {
@@ -452,7 +452,7 @@ class TransactionGroupTransformer extends AbstractTransformer
{
$result = $journal->transactions->first(
static function (Transaction $transaction) {
return (float)$transaction->amount > 0; // lame but it works
return (float) $transaction->amount > 0; // lame but it works
}
);
if (null === $result) {
@@ -556,7 +556,7 @@ class TransactionGroupTransformer extends AbstractTransformer
if (null === $bill) {
return $array;
}
$array['id'] = (string)$bill->id;
$array['id'] = (string) $bill->id;
$array['name'] = $bill->name;
return $array;