mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-01-10 12:24:50 +00:00
Reformat various code.
This commit is contained in:
@@ -62,8 +62,8 @@ class AccountTransformer extends AbstractTransformer
|
||||
|
||||
// get account type:
|
||||
$fullType = $account->accountType->type;
|
||||
$accountType = (string)config(sprintf('firefly.shortNamesByFullName.%s', $fullType));
|
||||
$liabilityType = (string)config(sprintf('firefly.shortLiabilityNameByFullName.%s', $fullType));
|
||||
$accountType = (string) config(sprintf('firefly.shortNamesByFullName.%s', $fullType));
|
||||
$liabilityType = (string) config(sprintf('firefly.shortLiabilityNameByFullName.%s', $fullType));
|
||||
$liabilityType = '' === $liabilityType ? null : strtolower($liabilityType);
|
||||
$liabilityDirection = $this->repository->getMetaValue($account, 'liability_direction');
|
||||
|
||||
@@ -77,7 +77,7 @@ class AccountTransformer extends AbstractTransformer
|
||||
[$openingBalance, $openingBalanceDate] = $this->getOpeningBalance($account, $accountType);
|
||||
[$interest, $interestPeriod] = $this->getInterest($account, $accountType);
|
||||
|
||||
$openingBalance = number_format((float)$openingBalance, $decimalPlaces, '.', '');
|
||||
$openingBalance = number_format((float) $openingBalance, $decimalPlaces, '.', '');
|
||||
$includeNetWorth = '0' !== $this->repository->getMetaValue($account, 'include_net_worth');
|
||||
$longitude = null;
|
||||
$latitude = null;
|
||||
@@ -86,17 +86,17 @@ class AccountTransformer extends AbstractTransformer
|
||||
if (null !== $location) {
|
||||
$longitude = $location->longitude;
|
||||
$latitude = $location->latitude;
|
||||
$zoomLevel = (int)$location->zoom_level;
|
||||
$zoomLevel = (int) $location->zoom_level;
|
||||
}
|
||||
|
||||
// no order for some accounts:
|
||||
$order = (int)$account->order;
|
||||
$order = (int) $account->order;
|
||||
if (!in_array(strtolower($accountType), ['liability', 'liabilities', 'asset'])) {
|
||||
$order = null;
|
||||
}
|
||||
|
||||
return [
|
||||
'id' => (string)$account->id,
|
||||
'id' => (string) $account->id,
|
||||
'created_at' => $account->created_at->toAtomString(),
|
||||
'updated_at' => $account->updated_at->toAtomString(),
|
||||
'active' => $account->active,
|
||||
@@ -108,7 +108,7 @@ class AccountTransformer extends AbstractTransformer
|
||||
'currency_code' => $currencyCode,
|
||||
'currency_symbol' => $currencySymbol,
|
||||
'currency_decimal_places' => $decimalPlaces,
|
||||
'current_balance' => number_format((float)app('steam')->balance($account, $date), $decimalPlaces, '.', ''),
|
||||
'current_balance' => number_format((float) app('steam')->balance($account, $date), $decimalPlaces, '.', ''),
|
||||
'current_balance_date' => $date->toAtomString(),
|
||||
'notes' => $this->repository->getNoteText($account),
|
||||
'monthly_payment_date' => $monthlyPaymentDate,
|
||||
@@ -116,7 +116,7 @@ class AccountTransformer extends AbstractTransformer
|
||||
'account_number' => $this->repository->getMetaValue($account, 'account_number'),
|
||||
'iban' => '' === $account->iban ? null : $account->iban,
|
||||
'bic' => $this->repository->getMetaValue($account, 'BIC'),
|
||||
'virtual_balance' => number_format((float)$account->virtual_balance, $decimalPlaces, '.', ''),
|
||||
'virtual_balance' => number_format((float) $account->virtual_balance, $decimalPlaces, '.', ''),
|
||||
'opening_balance' => $openingBalance,
|
||||
'opening_balance_date' => $openingBalanceDate,
|
||||
'liability_type' => $liabilityType,
|
||||
@@ -147,7 +147,7 @@ class AccountTransformer extends AbstractTransformer
|
||||
private function getAccountRole(Account $account, string $accountType): ?string
|
||||
{
|
||||
$accountRole = $this->repository->getMetaValue($account, 'account_role');
|
||||
if ('asset' !== $accountType || '' === (string)$accountRole) {
|
||||
if ('asset' !== $accountType || '' === (string) $accountRole) {
|
||||
$accountRole = null;
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ class AccountTransformer extends AbstractTransformer
|
||||
if (null === $currency) {
|
||||
$currency = app('amount')->getDefaultCurrencyByUser($account->user);
|
||||
}
|
||||
$currencyId = (string)$currency->id;
|
||||
$currencyId = (string) $currency->id;
|
||||
$currencyCode = $currency->code;
|
||||
$decimalPlaces = $currency->decimal_places;
|
||||
$currencySymbol = $currency->symbol;
|
||||
|
||||
@@ -55,10 +55,10 @@ class AttachmentTransformer extends AbstractTransformer
|
||||
$this->repository->setUser($attachment->user);
|
||||
|
||||
return [
|
||||
'id' => (string)$attachment->id,
|
||||
'id' => (string) $attachment->id,
|
||||
'created_at' => $attachment->created_at->toAtomString(),
|
||||
'updated_at' => $attachment->updated_at->toAtomString(),
|
||||
'attachable_id' => (string)$attachment->attachable_id,
|
||||
'attachable_id' => (string) $attachment->attachable_id,
|
||||
'attachable_type' => str_replace('FireflyIII\\Models\\', '', $attachment->attachable_type),
|
||||
'md5' => $attachment->md5,
|
||||
'filename' => $attachment->filename,
|
||||
@@ -67,7 +67,7 @@ class AttachmentTransformer extends AbstractTransformer
|
||||
'title' => $attachment->title,
|
||||
'notes' => $this->repository->getNoteText($attachment),
|
||||
'mime' => $attachment->mime,
|
||||
'size' => (int)$attachment->size,
|
||||
'size' => (int) $attachment->size,
|
||||
'links' => [
|
||||
[
|
||||
'rel' => 'self',
|
||||
|
||||
@@ -62,14 +62,14 @@ class AvailableBudgetTransformer extends AbstractTransformer
|
||||
|
||||
$currency = $availableBudget->transactionCurrency;
|
||||
$data = [
|
||||
'id' => (string)$availableBudget->id,
|
||||
'id' => (string) $availableBudget->id,
|
||||
'created_at' => $availableBudget->created_at->toAtomString(),
|
||||
'updated_at' => $availableBudget->updated_at->toAtomString(),
|
||||
'currency_id' => (string)$currency->id,
|
||||
'currency_id' => (string) $currency->id,
|
||||
'currency_code' => $currency->code,
|
||||
'currency_symbol' => $currency->symbol,
|
||||
'currency_decimal_places' => (int)$currency->decimal_places,
|
||||
'amount' => number_format((float)$availableBudget->amount, $currency->decimal_places, '.', ''),
|
||||
'currency_decimal_places' => (int) $currency->decimal_places,
|
||||
'amount' => number_format((float) $availableBudget->amount, $currency->decimal_places, '.', ''),
|
||||
'start' => $availableBudget->start_date->toAtomString(),
|
||||
'end' => $availableBudget->end_date->endOfDay()->toAtomString(),
|
||||
'spent_in_budgets' => [],
|
||||
|
||||
@@ -71,8 +71,8 @@ class BillTransformer extends AbstractTransformer
|
||||
/** @var ObjectGroup $objectGroup */
|
||||
$objectGroup = $bill->objectGroups->first();
|
||||
if (null !== $objectGroup) {
|
||||
$objectGroupId = (int)$objectGroup->id;
|
||||
$objectGroupOrder = (int)$objectGroup->order;
|
||||
$objectGroupId = (int) $objectGroup->id;
|
||||
$objectGroupOrder = (int) $objectGroup->order;
|
||||
$objectGroupTitle = $objectGroup->title;
|
||||
}
|
||||
|
||||
@@ -106,25 +106,25 @@ class BillTransformer extends AbstractTransformer
|
||||
unset($temp, $temp2);
|
||||
|
||||
return [
|
||||
'id' => (int)$bill->id,
|
||||
'id' => (int) $bill->id,
|
||||
'created_at' => $bill->created_at->toAtomString(),
|
||||
'updated_at' => $bill->updated_at->toAtomString(),
|
||||
'currency_id' => (string)$bill->transaction_currency_id,
|
||||
'currency_id' => (string) $bill->transaction_currency_id,
|
||||
'currency_code' => $currency->code,
|
||||
'currency_symbol' => $currency->symbol,
|
||||
'currency_decimal_places' => (int)$currency->decimal_places,
|
||||
'currency_decimal_places' => (int) $currency->decimal_places,
|
||||
'name' => $bill->name,
|
||||
'amount_min' => number_format((float)$bill->amount_min, $currency->decimal_places, '.', ''),
|
||||
'amount_max' => number_format((float)$bill->amount_max, $currency->decimal_places, '.', ''),
|
||||
'amount_min' => number_format((float) $bill->amount_min, $currency->decimal_places, '.', ''),
|
||||
'amount_max' => number_format((float) $bill->amount_max, $currency->decimal_places, '.', ''),
|
||||
'date' => $bill->date->toAtomString(),
|
||||
'end_date' => $bill->end_date?->toAtomString(),
|
||||
'extension_date' => $bill->extension_date?->toAtomString(),
|
||||
'repeat_freq' => $bill->repeat_freq,
|
||||
'skip' => (int)$bill->skip,
|
||||
'skip' => (int) $bill->skip,
|
||||
'active' => $bill->active,
|
||||
'order' => (int)$bill->order,
|
||||
'order' => (int) $bill->order,
|
||||
'notes' => $notes,
|
||||
'object_group_id' => $objectGroupId ? (string)$objectGroupId : null,
|
||||
'object_group_id' => $objectGroupId ? (string) $objectGroupId : null,
|
||||
'object_group_order' => $objectGroupOrder,
|
||||
'object_group_title' => $objectGroupTitle,
|
||||
|
||||
@@ -202,8 +202,8 @@ class BillTransformer extends AbstractTransformer
|
||||
$result = [];
|
||||
foreach ($set as $entry) {
|
||||
$result[] = [
|
||||
'transaction_group_id' => (int)$entry->transaction_group_id,
|
||||
'transaction_journal_id' => (int)$entry->id,
|
||||
'transaction_group_id' => (int) $entry->transaction_group_id,
|
||||
'transaction_journal_id' => (int) $entry->id,
|
||||
'date' => $entry->date->format('Y-m-d'),
|
||||
];
|
||||
}
|
||||
@@ -267,7 +267,7 @@ class BillTransformer extends AbstractTransformer
|
||||
$nextExpectedMatch->addDay();
|
||||
$currentStart = clone $nextExpectedMatch;
|
||||
$loop++;
|
||||
if($loop > 4) {
|
||||
if ($loop > 4) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,22 +74,22 @@ class BudgetLimitTransformer extends AbstractTransformer
|
||||
$currencySymbol = null;
|
||||
if (null !== $currency) {
|
||||
$amount = $budgetLimit->amount;
|
||||
$currencyId = (int)$currency->id;
|
||||
$currencyId = (int) $currency->id;
|
||||
$currencyName = $currency->name;
|
||||
$currencyCode = $currency->code;
|
||||
$currencySymbol = $currency->symbol;
|
||||
$currencyDecimalPlaces = $currency->decimal_places;
|
||||
}
|
||||
$amount = number_format((float)$amount, $currencyDecimalPlaces, '.', '');
|
||||
$amount = number_format((float) $amount, $currencyDecimalPlaces, '.', '');
|
||||
|
||||
return [
|
||||
'id' => (string)$budgetLimit->id,
|
||||
'id' => (string) $budgetLimit->id,
|
||||
'created_at' => $budgetLimit->created_at->toAtomString(),
|
||||
'updated_at' => $budgetLimit->updated_at->toAtomString(),
|
||||
'start' => $budgetLimit->start_date->toAtomString(),
|
||||
'end' => $budgetLimit->end_date->endOfDay()->toAtomString(),
|
||||
'budget_id' => (string)$budgetLimit->budget_id,
|
||||
'currency_id' => (string)$currencyId,
|
||||
'budget_id' => (string) $budgetLimit->budget_id,
|
||||
'currency_id' => (string) $currencyId,
|
||||
'currency_code' => $currencyCode,
|
||||
'currency_name' => $currencyName,
|
||||
'currency_decimal_places' => $currencyDecimalPlaces,
|
||||
|
||||
@@ -70,7 +70,7 @@ class CategoryTransformer extends AbstractTransformer
|
||||
$notes = $this->repository->getNoteText($category);
|
||||
|
||||
return [
|
||||
'id' => (int)$category->id,
|
||||
'id' => (int) $category->id,
|
||||
'created_at' => $category->created_at->toAtomString(),
|
||||
'updated_at' => $category->updated_at->toAtomString(),
|
||||
'name' => $category->name,
|
||||
@@ -95,7 +95,7 @@ class CategoryTransformer extends AbstractTransformer
|
||||
{
|
||||
$return = [];
|
||||
foreach ($array as $data) {
|
||||
$data['sum'] = number_format((float)$data['sum'], (int)$data['currency_decimal_places'], '.', '');
|
||||
$data['sum'] = number_format((float) $data['sum'], (int) $data['currency_decimal_places'], '.', '');
|
||||
$return[] = $data;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,11 +43,11 @@ class CurrencyTransformer extends AbstractTransformer
|
||||
$isDefault = false;
|
||||
$defaultCurrency = $this->parameters->get('defaultCurrency');
|
||||
if (null !== $defaultCurrency) {
|
||||
$isDefault = (int)$defaultCurrency->id === (int)$currency->id;
|
||||
$isDefault = (int) $defaultCurrency->id === (int) $currency->id;
|
||||
}
|
||||
|
||||
return [
|
||||
'id' => (int)$currency->id,
|
||||
'id' => (int) $currency->id,
|
||||
'created_at' => $currency->created_at->toAtomString(),
|
||||
'updated_at' => $currency->updated_at->toAtomString(),
|
||||
'default' => $isDefault,
|
||||
@@ -55,7 +55,7 @@ class CurrencyTransformer extends AbstractTransformer
|
||||
'name' => $currency->name,
|
||||
'code' => $currency->code,
|
||||
'symbol' => $currency->symbol,
|
||||
'decimal_places' => (int)$currency->decimal_places,
|
||||
'decimal_places' => (int) $currency->decimal_places,
|
||||
'links' => [
|
||||
[
|
||||
'rel' => 'self',
|
||||
|
||||
@@ -41,7 +41,7 @@ class LinkTypeTransformer extends AbstractTransformer
|
||||
public function transform(LinkType $linkType): array
|
||||
{
|
||||
return [
|
||||
'id' => (int)$linkType->id,
|
||||
'id' => (int) $linkType->id,
|
||||
'created_at' => $linkType->created_at->toAtomString(),
|
||||
'updated_at' => $linkType->updated_at->toAtomString(),
|
||||
'name' => $linkType->name,
|
||||
|
||||
@@ -56,11 +56,11 @@ class ObjectGroupTransformer extends AbstractTransformer
|
||||
$this->repository->setUser($objectGroup->user);
|
||||
|
||||
return [
|
||||
'id' => (string)$objectGroup->id,
|
||||
'id' => (string) $objectGroup->id,
|
||||
'created_at' => $objectGroup->created_at->toAtomString(),
|
||||
'updated_at' => $objectGroup->updated_at->toAtomString(),
|
||||
'title' => $objectGroup->title,
|
||||
'order' => (int)$objectGroup->order,
|
||||
'order' => (int) $objectGroup->order,
|
||||
'links' => [
|
||||
[
|
||||
'rel' => 'self',
|
||||
|
||||
@@ -72,22 +72,22 @@ class PiggyBankEventTransformer extends AbstractTransformer
|
||||
// get associated journal and transaction, if any:
|
||||
$journalId = $event->transaction_journal_id;
|
||||
$groupId = null;
|
||||
if (0 !== (int)$journalId) {
|
||||
$groupId = (int)$event->transactionJournal->transaction_group_id;
|
||||
$journalId = (int)$journalId;
|
||||
if (0 !== (int) $journalId) {
|
||||
$groupId = (int) $event->transactionJournal->transaction_group_id;
|
||||
$journalId = (int) $journalId;
|
||||
}
|
||||
|
||||
return [
|
||||
'id' => (string)$event->id,
|
||||
'id' => (string) $event->id,
|
||||
'created_at' => $event->created_at->toAtomString(),
|
||||
'updated_at' => $event->updated_at->toAtomString(),
|
||||
'amount' => number_format((float)$event->amount, $currency->decimal_places, '.', ''),
|
||||
'currency_id' => (string)$currency->id,
|
||||
'amount' => number_format((float) $event->amount, $currency->decimal_places, '.', ''),
|
||||
'currency_id' => (string) $currency->id,
|
||||
'currency_code' => $currency->code,
|
||||
'currency_symbol' => $currency->symbol,
|
||||
'currency_decimal_places' => (int)$currency->decimal_places,
|
||||
'transaction_journal_id' => $journalId ? (string)$journalId : null,
|
||||
'transaction_group_id' => $groupId ? (string)$groupId : null,
|
||||
'currency_decimal_places' => (int) $currency->decimal_places,
|
||||
'transaction_journal_id' => $journalId ? (string) $journalId : null,
|
||||
'transaction_group_id' => $groupId ? (string) $groupId : null,
|
||||
'links' => [
|
||||
[
|
||||
'rel' => 'self',
|
||||
|
||||
@@ -40,7 +40,7 @@ class PreferenceTransformer extends AbstractTransformer
|
||||
public function transform(Preference $preference): array
|
||||
{
|
||||
return [
|
||||
'id' => (int)$preference->id,
|
||||
'id' => (int) $preference->id,
|
||||
'created_at' => $preference->created_at->toAtomString(),
|
||||
'updated_at' => $preference->updated_at->toAtomString(),
|
||||
'name' => $preference->name,
|
||||
|
||||
@@ -80,14 +80,14 @@ class RecurrenceTransformer extends AbstractTransformer
|
||||
$this->budgetRepos->setUser($recurrence->user);
|
||||
Log::debug('Set user.');
|
||||
|
||||
$shortType = (string)config(sprintf('firefly.transactionTypesToShort.%s', $recurrence->transactionType->type));
|
||||
$shortType = (string) config(sprintf('firefly.transactionTypesToShort.%s', $recurrence->transactionType->type));
|
||||
$notes = $this->repository->getNoteText($recurrence);
|
||||
$reps = 0 === (int)$recurrence->repetitions ? null : (int)$recurrence->repetitions;
|
||||
$reps = 0 === (int) $recurrence->repetitions ? null : (int) $recurrence->repetitions;
|
||||
Log::debug('Get basic data.');
|
||||
|
||||
// basic data.
|
||||
return [
|
||||
'id' => (string)$recurrence->id,
|
||||
'id' => (string) $recurrence->id,
|
||||
'created_at' => $recurrence->created_at->toAtomString(),
|
||||
'updated_at' => $recurrence->updated_at->toAtomString(),
|
||||
'type' => $shortType,
|
||||
@@ -126,13 +126,13 @@ class RecurrenceTransformer extends AbstractTransformer
|
||||
/** @var RecurrenceRepetition $repetition */
|
||||
foreach ($recurrence->recurrenceRepetitions as $repetition) {
|
||||
$repetitionArray = [
|
||||
'id' => (string)$repetition->id,
|
||||
'id' => (string) $repetition->id,
|
||||
'created_at' => $repetition->created_at->toAtomString(),
|
||||
'updated_at' => $repetition->updated_at->toAtomString(),
|
||||
'type' => $repetition->repetition_type,
|
||||
'moment' => $repetition->repetition_moment,
|
||||
'skip' => (int)$repetition->repetition_skip,
|
||||
'weekend' => (int)$repetition->weekend,
|
||||
'skip' => (int) $repetition->repetition_skip,
|
||||
'weekend' => (int) $repetition->weekend,
|
||||
'description' => $this->repository->repetitionDescription($repetition),
|
||||
'occurrences' => [],
|
||||
];
|
||||
@@ -171,10 +171,10 @@ class RecurrenceTransformer extends AbstractTransformer
|
||||
$foreignCurrencyDp = null;
|
||||
$foreignCurrencyId = null;
|
||||
if (null !== $transaction->foreign_currency_id) {
|
||||
$foreignCurrencyId = (int)$transaction->foreign_currency_id;
|
||||
$foreignCurrencyId = (int) $transaction->foreign_currency_id;
|
||||
$foreignCurrencyCode = $transaction->foreignCurrency->code;
|
||||
$foreignCurrencySymbol = $transaction->foreignCurrency->symbol;
|
||||
$foreignCurrencyDp = (int)$transaction->foreignCurrency->decimal_places;
|
||||
$foreignCurrencyDp = (int) $transaction->foreignCurrency->decimal_places;
|
||||
}
|
||||
|
||||
// source info:
|
||||
@@ -184,7 +184,7 @@ class RecurrenceTransformer extends AbstractTransformer
|
||||
$sourceIban = null;
|
||||
if (null !== $sourceAccount) {
|
||||
$sourceName = $sourceAccount->name;
|
||||
$sourceId = (int)$sourceAccount->id;
|
||||
$sourceId = (int) $sourceAccount->id;
|
||||
$sourceType = $sourceAccount->accountType->type;
|
||||
$sourceIban = $sourceAccount->iban;
|
||||
}
|
||||
@@ -194,29 +194,29 @@ class RecurrenceTransformer extends AbstractTransformer
|
||||
$destinationIban = null;
|
||||
if (null !== $destinationAccount) {
|
||||
$destinationName = $destinationAccount->name;
|
||||
$destinationId = (int)$destinationAccount->id;
|
||||
$destinationId = (int) $destinationAccount->id;
|
||||
$destinationType = $destinationAccount->accountType->type;
|
||||
$destinationIban = $destinationAccount->iban;
|
||||
}
|
||||
$amount = number_format((float)$transaction->amount, $transaction->transactionCurrency->decimal_places, '.', '');
|
||||
$amount = number_format((float) $transaction->amount, $transaction->transactionCurrency->decimal_places, '.', '');
|
||||
$foreignAmount = null;
|
||||
if (null !== $transaction->foreign_currency_id && null !== $transaction->foreign_amount) {
|
||||
$foreignAmount = number_format((float)$transaction->foreign_amount, $foreignCurrencyDp, '.', '');
|
||||
$foreignAmount = number_format((float) $transaction->foreign_amount, $foreignCurrencyDp, '.', '');
|
||||
}
|
||||
$transactionArray = [
|
||||
'currency_id' => (string)$transaction->transaction_currency_id,
|
||||
'currency_id' => (string) $transaction->transaction_currency_id,
|
||||
'currency_code' => $transaction->transactionCurrency->code,
|
||||
'currency_symbol' => $transaction->transactionCurrency->symbol,
|
||||
'currency_decimal_places' => (int)$transaction->transactionCurrency->decimal_places,
|
||||
'foreign_currency_id' => null === $foreignCurrencyId ? null : (string)$foreignCurrencyId,
|
||||
'currency_decimal_places' => (int) $transaction->transactionCurrency->decimal_places,
|
||||
'foreign_currency_id' => null === $foreignCurrencyId ? null : (string) $foreignCurrencyId,
|
||||
'foreign_currency_code' => $foreignCurrencyCode,
|
||||
'foreign_currency_symbol' => $foreignCurrencySymbol,
|
||||
'foreign_currency_decimal_places' => $foreignCurrencyDp,
|
||||
'source_id' => (string)$sourceId,
|
||||
'source_id' => (string) $sourceId,
|
||||
'source_name' => $sourceName,
|
||||
'source_iban' => $sourceIban,
|
||||
'source_type' => $sourceType,
|
||||
'destination_id' => (string)$destinationId,
|
||||
'destination_id' => (string) $destinationId,
|
||||
'destination_name' => $destinationName,
|
||||
'destination_iban' => $destinationIban,
|
||||
'destination_type' => $destinationType,
|
||||
@@ -264,9 +264,9 @@ class RecurrenceTransformer extends AbstractTransformer
|
||||
default:
|
||||
throw new FireflyException(sprintf('Recurrence transformer cant handle field "%s"', $transactionMeta->name));
|
||||
case 'bill_id':
|
||||
$bill = $this->billRepos->find((int)$transactionMeta->value);
|
||||
$bill = $this->billRepos->find((int) $transactionMeta->value);
|
||||
if (null !== $bill) {
|
||||
$array['bill_id'] = (string)$bill->id;
|
||||
$array['bill_id'] = (string) $bill->id;
|
||||
$array['bill_name'] = $bill->name;
|
||||
}
|
||||
break;
|
||||
@@ -274,30 +274,30 @@ class RecurrenceTransformer extends AbstractTransformer
|
||||
$array['tags'] = json_decode($transactionMeta->value);
|
||||
break;
|
||||
case 'piggy_bank_id':
|
||||
$piggy = $this->piggyRepos->find((int)$transactionMeta->value);
|
||||
$piggy = $this->piggyRepos->find((int) $transactionMeta->value);
|
||||
if (null !== $piggy) {
|
||||
$array['piggy_bank_id'] = (string)$piggy->id;
|
||||
$array['piggy_bank_id'] = (string) $piggy->id;
|
||||
$array['piggy_bank_name'] = $piggy->name;
|
||||
}
|
||||
break;
|
||||
case 'category_id':
|
||||
$category = $this->factory->findOrCreate((int)$transactionMeta->value, null);
|
||||
$category = $this->factory->findOrCreate((int) $transactionMeta->value, null);
|
||||
if (null !== $category) {
|
||||
$array['category_id'] = (string)$category->id;
|
||||
$array['category_id'] = (string) $category->id;
|
||||
$array['category_name'] = $category->name;
|
||||
}
|
||||
break;
|
||||
case 'category_name':
|
||||
$category = $this->factory->findOrCreate(null, $transactionMeta->value);
|
||||
if (null !== $category) {
|
||||
$array['category_id'] = (string)$category->id;
|
||||
$array['category_id'] = (string) $category->id;
|
||||
$array['category_name'] = $category->name;
|
||||
}
|
||||
break;
|
||||
case 'budget_id':
|
||||
$budget = $this->budgetRepos->find((int)$transactionMeta->value);
|
||||
$budget = $this->budgetRepos->find((int) $transactionMeta->value);
|
||||
if (null !== $budget) {
|
||||
$array['budget_id'] = (string)$budget->id;
|
||||
$array['budget_id'] = (string) $budget->id;
|
||||
$array['budget_name'] = $budget->name;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -41,7 +41,7 @@ class RuleGroupTransformer extends AbstractTransformer
|
||||
public function transform(RuleGroup $ruleGroup): array
|
||||
{
|
||||
return [
|
||||
'id' => (int)$ruleGroup->id,
|
||||
'id' => (int) $ruleGroup->id,
|
||||
'created_at' => $ruleGroup->created_at->toAtomString(),
|
||||
'updated_at' => $ruleGroup->updated_at->toAtomString(),
|
||||
'title' => $ruleGroup->title,
|
||||
|
||||
@@ -60,21 +60,21 @@ class RuleTransformer extends AbstractTransformer
|
||||
$this->ruleRepository->setUser($rule->user);
|
||||
|
||||
return [
|
||||
'id' => (string)$rule->id,
|
||||
'created_at' => $rule->created_at->toAtomString(),
|
||||
'updated_at' => $rule->updated_at->toAtomString(),
|
||||
'rule_group_id' => (string)$rule->rule_group_id,
|
||||
'rule_group_title' => (string)$rule->ruleGroup->title,
|
||||
'title' => $rule->title,
|
||||
'description' => $rule->description,
|
||||
'order' => (int)$rule->order,
|
||||
'active' => $rule->active,
|
||||
'strict' => $rule->strict,
|
||||
'stop_processing' => $rule->stop_processing,
|
||||
'trigger' => $this->getRuleTrigger($rule),
|
||||
'triggers' => $this->triggers($rule),
|
||||
'actions' => $this->actions($rule),
|
||||
'links' => [
|
||||
'id' => (string) $rule->id,
|
||||
'created_at' => $rule->created_at->toAtomString(),
|
||||
'updated_at' => $rule->updated_at->toAtomString(),
|
||||
'rule_group_id' => (string) $rule->rule_group_id,
|
||||
'rule_group_title' => (string) $rule->ruleGroup->title,
|
||||
'title' => $rule->title,
|
||||
'description' => $rule->description,
|
||||
'order' => (int) $rule->order,
|
||||
'active' => $rule->active,
|
||||
'strict' => $rule->strict,
|
||||
'stop_processing' => $rule->stop_processing,
|
||||
'trigger' => $this->getRuleTrigger($rule),
|
||||
'triggers' => $this->triggers($rule),
|
||||
'actions' => $this->actions($rule),
|
||||
'links' => [
|
||||
[
|
||||
'rel' => 'self',
|
||||
'uri' => '/rules/' . $rule->id,
|
||||
@@ -121,7 +121,7 @@ class RuleTransformer extends AbstractTransformer
|
||||
continue;
|
||||
}
|
||||
$result[] = [
|
||||
'id' => (string)$ruleTrigger->id,
|
||||
'id' => (string) $ruleTrigger->id,
|
||||
'created_at' => $ruleTrigger->created_at->toAtomString(),
|
||||
'updated_at' => $ruleTrigger->updated_at->toAtomString(),
|
||||
'type' => $ruleTrigger->trigger_type,
|
||||
@@ -147,7 +147,7 @@ class RuleTransformer extends AbstractTransformer
|
||||
/** @var RuleAction $ruleAction */
|
||||
foreach ($actions as $ruleAction) {
|
||||
$result[] = [
|
||||
'id' => (string)$ruleAction->id,
|
||||
'id' => (string) $ruleAction->id,
|
||||
'created_at' => $ruleAction->created_at->toAtomString(),
|
||||
'updated_at' => $ruleAction->updated_at->toAtomString(),
|
||||
'type' => $ruleAction->action_type,
|
||||
|
||||
@@ -52,11 +52,11 @@ class TagTransformer extends AbstractTransformer
|
||||
if (null !== $location) {
|
||||
$latitude = $location->latitude;
|
||||
$longitude = $location->longitude;
|
||||
$zoomLevel = (int)$location->zoom_level;
|
||||
$zoomLevel = (int) $location->zoom_level;
|
||||
}
|
||||
|
||||
return [
|
||||
'id' => (int)$tag->id,
|
||||
'id' => (int) $tag->id,
|
||||
'created_at' => $tag->created_at->toAtomString(),
|
||||
'updated_at' => $tag->updated_at->toAtomString(),
|
||||
'tag' => $tag->tag,
|
||||
|
||||
@@ -75,10 +75,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' => [
|
||||
@@ -123,13 +123,13 @@ class TransactionGroupTransformer extends AbstractTransformer
|
||||
$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);
|
||||
|
||||
$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;
|
||||
@@ -137,17 +137,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'],
|
||||
@@ -159,12 +159,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'],
|
||||
@@ -179,8 +179,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'],
|
||||
@@ -213,7 +213,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']),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -230,11 +230,11 @@ class TransactionGroupTransformer extends AbstractTransformer
|
||||
return null;
|
||||
}
|
||||
if (array_key_exists($key, $array) && null !== $array[$key]) {
|
||||
return (string)$array[$key];
|
||||
return (string) $array[$key];
|
||||
}
|
||||
|
||||
if (null !== $default) {
|
||||
return (string)$default;
|
||||
return (string) $default;
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -250,16 +250,6 @@ class TransactionGroupTransformer extends AbstractTransformer
|
||||
return $this->groupRepos->getLocation($journalId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $journalId
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function hasAttachments(int $journalId): bool
|
||||
{
|
||||
return $this->groupRepos->countAttachments($journalId) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $array
|
||||
* @param string $key
|
||||
@@ -269,7 +259,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;
|
||||
@@ -290,6 +280,16 @@ class TransactionGroupTransformer extends AbstractTransformer
|
||||
return $object[$key]->toAtomString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $journalId
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function hasAttachments(int $journalId): bool
|
||||
{
|
||||
return $this->groupRepos->countAttachments($journalId) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionGroup $group
|
||||
*
|
||||
@@ -300,10 +300,10 @@ class TransactionGroupTransformer extends AbstractTransformer
|
||||
{
|
||||
try {
|
||||
$result = [
|
||||
'id' => (int)$group->id,
|
||||
'id' => (int) $group->id,
|
||||
'created_at' => $group->created_at->toAtomString(),
|
||||
'updated_at' => $group->updated_at->toAtomString(),
|
||||
'user' => (int)$group->user_id,
|
||||
'user' => (int) $group->user_id,
|
||||
'group_title' => $group->title,
|
||||
'transactions' => $this->transformJournals($group->transactionJournals),
|
||||
'links' => [
|
||||
@@ -363,7 +363,7 @@ class TransactionGroupTransformer extends AbstractTransformer
|
||||
$bill = $this->getBill($journal->bill);
|
||||
|
||||
if (null !== $foreignAmount && null !== $foreignCurrency) {
|
||||
$foreignAmount = number_format((float)$foreignAmount, $foreignCurrency['decimal_places'] ?? 0, '.', '');
|
||||
$foreignAmount = number_format((float) $foreignAmount, $foreignCurrency['decimal_places'] ?? 0, '.', '');
|
||||
}
|
||||
|
||||
$longitude = null;
|
||||
@@ -377,33 +377,33 @@ class TransactionGroupTransformer extends AbstractTransformer
|
||||
}
|
||||
|
||||
return [
|
||||
'user' => (int)$journal->user_id,
|
||||
'transaction_journal_id' => (int)$journal->id,
|
||||
'user' => (int) $journal->user_id,
|
||||
'transaction_journal_id' => (int) $journal->id,
|
||||
'type' => strtolower($type),
|
||||
'date' => $journal->date->toAtomString(),
|
||||
'order' => $journal->order,
|
||||
|
||||
'currency_id' => (int)$currency->id,
|
||||
'currency_id' => (int) $currency->id,
|
||||
'currency_code' => $currency->code,
|
||||
'currency_symbol' => $currency->symbol,
|
||||
'currency_decimal_places' => (int)$currency->decimal_places,
|
||||
'currency_decimal_places' => (int) $currency->decimal_places,
|
||||
|
||||
'foreign_currency_id' => $foreignCurrency['id'],
|
||||
'foreign_currency_code' => $foreignCurrency['code'],
|
||||
'foreign_currency_symbol' => $foreignCurrency['symbol'],
|
||||
'foreign_currency_decimal_places' => $foreignCurrency['decimal_places'],
|
||||
|
||||
'amount' => number_format((float)$amount, $currency->decimal_places, '.', ''),
|
||||
'amount' => number_format((float) $amount, $currency->decimal_places, '.', ''),
|
||||
'foreign_amount' => $foreignAmount,
|
||||
|
||||
'description' => $journal->description,
|
||||
|
||||
'source_id' => (int)$source->account_id,
|
||||
'source_id' => (int) $source->account_id,
|
||||
'source_name' => $source->account->name,
|
||||
'source_iban' => $source->account->iban,
|
||||
'source_type' => $source->account->accountType->type,
|
||||
|
||||
'destination_id' => (int)$destination->account_id,
|
||||
'destination_id' => (int) $destination->account_id,
|
||||
'destination_name' => $destination->account->name,
|
||||
'destination_iban' => $destination->account->iban,
|
||||
'destination_type' => $destination->account->accountType->type,
|
||||
@@ -461,7 +461,7 @@ class TransactionGroupTransformer extends AbstractTransformer
|
||||
{
|
||||
$result = $journal->transactions->first(
|
||||
static function (Transaction $transaction) {
|
||||
return (float)$transaction->amount < 0;
|
||||
return (float) $transaction->amount < 0;
|
||||
}
|
||||
);
|
||||
if (null === $result) {
|
||||
@@ -481,7 +481,7 @@ class TransactionGroupTransformer extends AbstractTransformer
|
||||
{
|
||||
$result = $journal->transactions->first(
|
||||
static function (Transaction $transaction) {
|
||||
return (float)$transaction->amount > 0;
|
||||
return (float) $transaction->amount > 0;
|
||||
}
|
||||
);
|
||||
if (null === $result) {
|
||||
@@ -565,10 +565,10 @@ class TransactionGroupTransformer extends AbstractTransformer
|
||||
if (null === $currency) {
|
||||
return $array;
|
||||
}
|
||||
$array['id'] = (int)$currency->id;
|
||||
$array['id'] = (int) $currency->id;
|
||||
$array['code'] = $currency->code;
|
||||
$array['symbol'] = $currency->symbol;
|
||||
$array['decimal_places'] = (int)$currency->decimal_places;
|
||||
$array['decimal_places'] = (int) $currency->decimal_places;
|
||||
|
||||
return $array;
|
||||
}
|
||||
@@ -587,7 +587,7 @@ class TransactionGroupTransformer extends AbstractTransformer
|
||||
if (null === $budget) {
|
||||
return $array;
|
||||
}
|
||||
$array['id'] = (int)$budget->id;
|
||||
$array['id'] = (int) $budget->id;
|
||||
$array['name'] = $budget->name;
|
||||
|
||||
return $array;
|
||||
@@ -607,7 +607,7 @@ class TransactionGroupTransformer extends AbstractTransformer
|
||||
if (null === $category) {
|
||||
return $array;
|
||||
}
|
||||
$array['id'] = (int)$category->id;
|
||||
$array['id'] = (int) $category->id;
|
||||
$array['name'] = $category->name;
|
||||
|
||||
return $array;
|
||||
@@ -627,7 +627,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;
|
||||
|
||||
@@ -55,12 +55,12 @@ class TransactionLinkTransformer extends AbstractTransformer
|
||||
$notes = $this->repository->getLinkNoteText($link);
|
||||
|
||||
return [
|
||||
'id' => (string)$link->id,
|
||||
'id' => (string) $link->id,
|
||||
'created_at' => $link->created_at->toAtomString(),
|
||||
'updated_at' => $link->updated_at->toAtomString(),
|
||||
'inward_id' => (string)$link->source_id,
|
||||
'outward_id' => (string)$link->destination_id,
|
||||
'link_type_id' => (string)$link->link_type_id,
|
||||
'inward_id' => (string) $link->source_id,
|
||||
'outward_id' => (string) $link->destination_id,
|
||||
'link_type_id' => (string) $link->link_type_id,
|
||||
'notes' => '' === $notes ? null : $notes,
|
||||
'links' => [
|
||||
[
|
||||
|
||||
@@ -46,11 +46,11 @@ class UserTransformer extends AbstractTransformer
|
||||
$this->repository = $this->repository ?? app(UserRepositoryInterface::class);
|
||||
|
||||
return [
|
||||
'id' => (int)$user->id,
|
||||
'id' => (int) $user->id,
|
||||
'created_at' => $user->created_at->toAtomString(),
|
||||
'updated_at' => $user->updated_at->toAtomString(),
|
||||
'email' => $user->email,
|
||||
'blocked' => 1 === (int)$user->blocked,
|
||||
'blocked' => 1 === (int) $user->blocked,
|
||||
'blocked_code' => '' === $user->blocked_code ? null : $user->blocked_code,
|
||||
'role' => $this->repository->getRoleByUser($user),
|
||||
'links' => [
|
||||
|
||||
@@ -40,11 +40,11 @@ class WebhookAttemptTransformer extends AbstractTransformer
|
||||
public function transform(WebhookAttempt $attempt): array
|
||||
{
|
||||
return [
|
||||
'id' => (string)$attempt->id,
|
||||
'id' => (string) $attempt->id,
|
||||
'created_at' => $attempt->created_at->toAtomString(),
|
||||
'updated_at' => $attempt->updated_at->toAtomString(),
|
||||
'webhook_message_id' => (string)$attempt->webhook_message_id,
|
||||
'status_code' => (int)$attempt->status_code,
|
||||
'webhook_message_id' => (string) $attempt->webhook_message_id,
|
||||
'status_code' => (int) $attempt->status_code,
|
||||
'logs' => $attempt->logs,
|
||||
'response' => $attempt->response,
|
||||
];
|
||||
|
||||
@@ -50,12 +50,12 @@ class WebhookMessageTransformer extends AbstractTransformer
|
||||
}
|
||||
|
||||
return [
|
||||
'id' => (string)$message->id,
|
||||
'id' => (string) $message->id,
|
||||
'created_at' => $message->created_at->toAtomString(),
|
||||
'updated_at' => $message->updated_at->toAtomString(),
|
||||
'sent' => $message->sent,
|
||||
'errored' => $message->errored,
|
||||
'webhook_id' => (string)$message->webhook_id,
|
||||
'webhook_id' => (string) $message->webhook_id,
|
||||
'uuid' => $message->uuid,
|
||||
'message' => $json,
|
||||
];
|
||||
|
||||
@@ -52,7 +52,7 @@ class WebhookTransformer extends AbstractTransformer
|
||||
public function transform(Webhook $webhook): array
|
||||
{
|
||||
return [
|
||||
'id' => (int)$webhook->id,
|
||||
'id' => (int) $webhook->id,
|
||||
'created_at' => $webhook->created_at->toAtomString(),
|
||||
'updated_at' => $webhook->updated_at->toAtomString(),
|
||||
'active' => $webhook->active,
|
||||
|
||||
Reference in New Issue
Block a user