small experimental code cleanup

This commit is contained in:
James Cole 2023-12-22 07:49:55 +01:00
parent 58dea55d38
commit 4864ecc0c7
No known key found for this signature in database
GPG Key ID: B49A324B7EAD6D80
13 changed files with 27 additions and 27 deletions

View File

@ -79,7 +79,7 @@ class AccountController extends Controller
$return = []; $return = [];
$result = $this->repository->searchAccount((string)$query, $types, $this->parameters->get('limit')); $result = $this->repository->searchAccount((string) $query, $types, $this->parameters->get('limit'));
// TODO this code is duplicated in the V2 Autocomplete controller, which means this code is due to be deprecated. // TODO this code is duplicated in the V2 Autocomplete controller, which means this code is due to be deprecated.
$defaultCurrency = app('amount')->getDefaultCurrency(); $defaultCurrency = app('amount')->getDefaultCurrency();
@ -98,11 +98,11 @@ class AccountController extends Controller
} }
$return[] = [ $return[] = [
'id' => (string)$account->id, 'id' => (string) $account->id,
'name' => $account->name, 'name' => $account->name,
'name_with_balance' => $nameWithBalance, 'name_with_balance' => $nameWithBalance,
'type' => $account->accountType->type, 'type' => $account->accountType->type,
'currency_id' => (string)$currency->id, 'currency_id' => (string) $currency->id,
'currency_name' => $currency->name, 'currency_name' => $currency->name,
'currency_code' => $currency->code, 'currency_code' => $currency->code,
'currency_symbol' => $currency->symbol, 'currency_symbol' => $currency->symbol,
@ -115,8 +115,8 @@ class AccountController extends Controller
$return, $return,
static function (array $left, array $right) { static function (array $left, array $right) {
$order = [AccountType::ASSET, AccountType::REVENUE, AccountType::EXPENSE]; $order = [AccountType::ASSET, AccountType::REVENUE, AccountType::EXPENSE];
$posA = (int)array_search($left['type'], $order, true); $posA = (int) array_search($left['type'], $order, true);
$posB = (int)array_search($right['type'], $order, true); $posB = (int) array_search($right['type'], $order, true);
return $posA - $posB; return $posA - $posB;
} }

View File

@ -66,7 +66,7 @@ class BillController extends Controller
$filtered = $result->map( $filtered = $result->map(
static function (Bill $item) { static function (Bill $item) {
return [ return [
'id' => (string)$item->id, 'id' => (string) $item->id,
'name' => $item->name, 'name' => $item->name,
'active' => $item->active, 'active' => $item->active,
]; ];

View File

@ -66,7 +66,7 @@ class BudgetController extends Controller
$filtered = $result->map( $filtered = $result->map(
static function (Budget $item) { static function (Budget $item) {
return [ return [
'id' => (string)$item->id, 'id' => (string) $item->id,
'name' => $item->name, 'name' => $item->name,
]; ];
} }

View File

@ -66,7 +66,7 @@ class CategoryController extends Controller
$filtered = $result->map( $filtered = $result->map(
static function (Category $item) { static function (Category $item) {
return [ return [
'id' => (string)$item->id, 'id' => (string) $item->id,
'name' => $item->name, 'name' => $item->name,
]; ];
} }

View File

@ -68,7 +68,7 @@ class CurrencyController extends Controller
/** @var TransactionCurrency $currency */ /** @var TransactionCurrency $currency */
foreach ($collection as $currency) { foreach ($collection as $currency) {
$result[] = [ $result[] = [
'id' => (string)$currency->id, 'id' => (string) $currency->id,
'name' => $currency->name, 'name' => $currency->name,
'code' => $currency->code, 'code' => $currency->code,
'symbol' => $currency->symbol, 'symbol' => $currency->symbol,
@ -94,7 +94,7 @@ class CurrencyController extends Controller
/** @var TransactionCurrency $currency */ /** @var TransactionCurrency $currency */
foreach ($collection as $currency) { foreach ($collection as $currency) {
$result[] = [ $result[] = [
'id' => (string)$currency->id, 'id' => (string) $currency->id,
'name' => sprintf('%s (%s)', $currency->name, $currency->code), 'name' => sprintf('%s (%s)', $currency->name, $currency->code),
'code' => $currency->code, 'code' => $currency->code,
'symbol' => $currency->symbol, 'symbol' => $currency->symbol,

View File

@ -68,7 +68,7 @@ class ObjectGroupController extends Controller
/** @var ObjectGroup $objectGroup */ /** @var ObjectGroup $objectGroup */
foreach ($result as $objectGroup) { foreach ($result as $objectGroup) {
$return[] = [ $return[] = [
'id' => (string)$objectGroup->id, 'id' => (string) $objectGroup->id,
'name' => $objectGroup->title, 'name' => $objectGroup->title,
'title' => $objectGroup->title, 'title' => $objectGroup->title,
]; ];

View File

@ -75,14 +75,14 @@ class PiggyBankController extends Controller
$currency = $this->accountRepository->getAccountCurrency($piggy->account) ?? $defaultCurrency; $currency = $this->accountRepository->getAccountCurrency($piggy->account) ?? $defaultCurrency;
$objectGroup = $piggy->objectGroups()->first(); $objectGroup = $piggy->objectGroups()->first();
$response[] = [ $response[] = [
'id' => (string)$piggy->id, 'id' => (string) $piggy->id,
'name' => $piggy->name, 'name' => $piggy->name,
'currency_id' => (string)$currency->id, 'currency_id' => (string) $currency->id,
'currency_name' => $currency->name, 'currency_name' => $currency->name,
'currency_code' => $currency->code, 'currency_code' => $currency->code,
'currency_symbol' => $currency->symbol, 'currency_symbol' => $currency->symbol,
'currency_decimal_places' => $currency->decimal_places, 'currency_decimal_places' => $currency->decimal_places,
'object_group_id' => null === $objectGroup ? null : (string)$objectGroup->id, 'object_group_id' => null === $objectGroup ? null : (string) $objectGroup->id,
'object_group_title' => $objectGroup?->title, 'object_group_title' => $objectGroup?->title,
]; ];
} }
@ -107,7 +107,7 @@ class PiggyBankController extends Controller
$currentAmount = $this->piggyRepository->getRepetition($piggy)->currentamount ?? '0'; $currentAmount = $this->piggyRepository->getRepetition($piggy)->currentamount ?? '0';
$objectGroup = $piggy->objectGroups()->first(); $objectGroup = $piggy->objectGroups()->first();
$response[] = [ $response[] = [
'id' => (string)$piggy->id, 'id' => (string) $piggy->id,
'name' => $piggy->name, 'name' => $piggy->name,
'name_with_balance' => sprintf( 'name_with_balance' => sprintf(
'%s (%s / %s)', '%s (%s / %s)',
@ -115,12 +115,12 @@ class PiggyBankController extends Controller
app('amount')->formatAnything($currency, $currentAmount, false), app('amount')->formatAnything($currency, $currentAmount, false),
app('amount')->formatAnything($currency, $piggy->targetamount, false), app('amount')->formatAnything($currency, $piggy->targetamount, false),
), ),
'currency_id' => (string)$currency->id, 'currency_id' => (string) $currency->id,
'currency_name' => $currency->name, 'currency_name' => $currency->name,
'currency_code' => $currency->code, 'currency_code' => $currency->code,
'currency_symbol' => $currency->symbol, 'currency_symbol' => $currency->symbol,
'currency_decimal_places' => $currency->decimal_places, 'currency_decimal_places' => $currency->decimal_places,
'object_group_id' => null === $objectGroup ? null : (string)$objectGroup->id, 'object_group_id' => null === $objectGroup ? null : (string) $objectGroup->id,
'object_group_title' => $objectGroup?->title, 'object_group_title' => $objectGroup?->title,
]; ];
} }

View File

@ -66,7 +66,7 @@ class RecurrenceController extends Controller
/** @var Recurrence $recurrence */ /** @var Recurrence $recurrence */
foreach ($recurrences as $recurrence) { foreach ($recurrences as $recurrence) {
$response[] = [ $response[] = [
'id' => (string)$recurrence->id, 'id' => (string) $recurrence->id,
'name' => $recurrence->title, 'name' => $recurrence->title,
'description' => $recurrence->description, 'description' => $recurrence->description,
]; ];

View File

@ -65,7 +65,7 @@ class RuleController extends Controller
/** @var Rule $rule */ /** @var Rule $rule */
foreach ($rules as $rule) { foreach ($rules as $rule) {
$response[] = [ $response[] = [
'id' => (string)$rule->id, 'id' => (string) $rule->id,
'name' => $rule->title, 'name' => $rule->title,
'description' => $rule->description, 'description' => $rule->description,
]; ];

View File

@ -65,7 +65,7 @@ class RuleGroupController extends Controller
/** @var RuleGroup $group */ /** @var RuleGroup $group */
foreach ($groups as $group) { foreach ($groups as $group) {
$response[] = [ $response[] = [
'id' => (string)$group->id, 'id' => (string) $group->id,
'name' => $group->title, 'name' => $group->title,
'description' => $group->description, 'description' => $group->description,
]; ];

View File

@ -69,7 +69,7 @@ class TagController extends Controller
/** @var Tag $tag */ /** @var Tag $tag */
foreach ($result as $tag) { foreach ($result as $tag) {
$array[] = [ $array[] = [
'id' => (string)$tag->id, 'id' => (string) $tag->id,
'name' => $tag->tag, 'name' => $tag->tag,
'tag' => $tag->tag, 'tag' => $tag->tag,
]; ];

View File

@ -76,8 +76,8 @@ class TransactionController extends Controller
/** @var TransactionJournal $journal */ /** @var TransactionJournal $journal */
foreach ($filtered as $journal) { foreach ($filtered as $journal) {
$array[] = [ $array[] = [
'id' => (string)$journal->id, 'id' => (string) $journal->id,
'transaction_group_id' => (string)$journal->transaction_group_id, 'transaction_group_id' => (string) $journal->transaction_group_id,
'name' => $journal->description, 'name' => $journal->description,
'description' => $journal->description, 'description' => $journal->description,
]; ];
@ -96,7 +96,7 @@ class TransactionController extends Controller
$result = new Collection(); $result = new Collection();
if (is_numeric($data['query'])) { if (is_numeric($data['query'])) {
// search for group, not journal. // search for group, not journal.
$firstResult = $this->groupRepository->find((int)$data['query']); $firstResult = $this->groupRepository->find((int) $data['query']);
if (null !== $firstResult) { if (null !== $firstResult) {
// group may contain multiple journals, each a result: // group may contain multiple journals, each a result:
foreach ($firstResult->transactionJournals as $journal) { foreach ($firstResult->transactionJournals as $journal) {
@ -114,8 +114,8 @@ class TransactionController extends Controller
/** @var TransactionJournal $journal */ /** @var TransactionJournal $journal */
foreach ($result as $journal) { foreach ($result as $journal) {
$array[] = [ $array[] = [
'id' => (string)$journal->id, 'id' => (string) $journal->id,
'transaction_group_id' => (string)$journal->transaction_group_id, 'transaction_group_id' => (string) $journal->transaction_group_id,
'name' => sprintf('#%d: %s', $journal->transaction_group_id, $journal->description), 'name' => sprintf('#%d: %s', $journal->transaction_group_id, $journal->description),
'description' => sprintf('#%d: %s', $journal->transaction_group_id, $journal->description), 'description' => sprintf('#%d: %s', $journal->transaction_group_id, $journal->description),
]; ];

View File

@ -65,7 +65,7 @@ class TransactionTypeController extends Controller
foreach ($types as $type) { foreach ($types as $type) {
// different key for consistency. // different key for consistency.
$array[] = [ $array[] = [
'id' => (string)$type->id, 'id' => (string) $type->id,
'name' => $type->type, 'name' => $type->type,
'type' => $type->type, 'type' => $type->type,
]; ];