Clean up code.

This commit is contained in:
James Cole
2020-10-23 19:11:25 +02:00
parent 0845e1cb7d
commit 8dbd785ab8
57 changed files with 84 additions and 441 deletions

View File

@@ -60,8 +60,10 @@ abstract class Controller extends BaseController
$language = app('steam')->getLanguage(); $language = app('steam')->getLanguage();
app()->setLocale($language); app()->setLocale($language);
} }
return $next($request); return $next($request);
}); }
);
} }
@@ -73,7 +75,7 @@ abstract class Controller extends BaseController
private function getParameters(): ParameterBag private function getParameters(): ParameterBag
{ {
$bag = new ParameterBag; $bag = new ParameterBag;
$page = (int) request()->get('page'); $page = (int)request()->get('page');
if (0 === $page) { if (0 === $page) {
$page = 1; $page = 1;
} }
@@ -100,7 +102,7 @@ abstract class Controller extends BaseController
foreach ($integers as $integer) { foreach ($integers as $integer) {
$value = request()->query->get($integer); $value = request()->query->get($integer);
if (null !== $value) { if (null !== $value) {
$bag->set($integer, (int) $value); $bag->set($integer, (int)$value);
} }
} }
@@ -127,9 +129,8 @@ abstract class Controller extends BaseController
} }
$params[$key] = $value; $params[$key] = $value;
} }
$return .= http_build_query($params);
return $return; return $return . http_build_query($params);
} }
/** /**

View File

@@ -132,8 +132,6 @@ class AccountStoreRequest extends FormRequest
'interest_period' => 'required_if:type,liability|in:daily,monthly,yearly', 'interest_period' => 'required_if:type,liability|in:daily,monthly,yearly',
'notes' => 'min:0|max:65536', 'notes' => 'min:0|max:65536',
]; ];
$rules = Location::requestRules($rules); return Location::requestRules($rules);
return $rules;
} }
} }

View File

@@ -134,8 +134,6 @@ class AccountUpdateRequest extends FormRequest
'interest_period' => 'required_if:type,liability|in:daily,monthly,yearly', 'interest_period' => 'required_if:type,liability|in:daily,monthly,yearly',
'notes' => 'min:0|max:65536', 'notes' => 'min:0|max:65536',
]; ];
$rules = Location::requestRules($rules); return Location::requestRules($rules);
return $rules;
} }
} }

View File

@@ -67,10 +67,7 @@ class RuleGroupTestRequest extends FormRequest
*/ */
private function getDate(string $field): ?Carbon private function getDate(string $field): ?Carbon
{ {
/** @var Carbon $result */ return null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', $this->query($field));
$result = null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', $this->query($field));
return $result;
} }
/** /**

View File

@@ -66,7 +66,6 @@ class RuleGroupTriggerRequest extends FormRequest
*/ */
private function getDate(string $field): ?Carbon private function getDate(string $field): ?Carbon
{ {
/** @var Carbon $result */
return null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', $this->query($field)); return null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', $this->query($field));
} }

View File

@@ -77,10 +77,7 @@ class RuleTestRequest extends FormRequest
*/ */
private function getDate(string $field): ?Carbon private function getDate(string $field): ?Carbon
{ {
/** @var Carbon $result */ return null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', $this->query($field));
$result = null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', $this->query($field));
return $result;
} }
/** /**

View File

@@ -40,21 +40,7 @@ class BillFactory
{ {
use BillServiceTrait, CreatesObjectGroups; use BillServiceTrait, CreatesObjectGroups;
/** @var User */ private User $user;
private $user;
/**
* Constructor.
*
* @codeCoverageIgnore
*/
public function __construct()
{
if ('testing' === config('app.env')) {
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', get_class($this)));
}
}
/** /**
* @param array $data * @param array $data
@@ -153,11 +139,7 @@ class BillFactory
*/ */
public function findByName(string $name): ?Bill public function findByName(string $name): ?Bill
{ {
$query = sprintf('%%%s%%', $name); return $this->user->bills()->where('name', 'LIKE', sprintf('%%%s%%', $name))->first();
/** @var Bill $first */
$first = $this->user->bills()->where('name', 'LIKE', $query)->first();
return $first;
} }
/** /**

View File

@@ -32,21 +32,7 @@ use Log;
*/ */
class BudgetFactory class BudgetFactory
{ {
/** @var User */ private User $user;
private $user;
/**
* Constructor.
*
* @codeCoverageIgnore
*/
public function __construct()
{
if ('testing' === config('app.env')) {
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', get_class($this)));
}
}
/** /**
* @param int|null $budgetId * @param int|null $budgetId

View File

@@ -35,21 +35,7 @@ use Log;
*/ */
class CategoryFactory class CategoryFactory
{ {
/** @var User */ private User $user;
private $user;
/**
* Constructor.
*
* @codeCoverageIgnore
*/
public function __construct()
{
if ('testing' === config('app.env')) {
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', get_class($this)));
}
}
/** /**
* @param string $name * @param string $name

View File

@@ -37,18 +37,6 @@ use Log;
*/ */
class PiggyBankEventFactory class PiggyBankEventFactory
{ {
/**
* Constructor.
*
* @codeCoverageIgnore
*/
public function __construct()
{
if ('testing' === config('app.env')) {
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', get_class($this)));
}
}
/** /**
* @param TransactionJournal $journal * @param TransactionJournal $journal
* @param PiggyBank|null $piggyBank * @param PiggyBank|null $piggyBank

View File

@@ -33,21 +33,7 @@ use Log;
*/ */
class PiggyBankFactory class PiggyBankFactory
{ {
/** @var User */ private User $user;
private $user;
/**
* Constructor.
*
* @codeCoverageIgnore
*/
public function __construct()
{
if ('testing' === config('app.env')) {
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', get_class($this)));
}
}
/** /**
* @param int|null $piggyBankId * @param int|null $piggyBankId

View File

@@ -209,7 +209,7 @@ class ChartJsGenerator implements GeneratorInterface
*/ */
public function singleSet(string $setLabel, array $data): array public function singleSet(string $setLabel, array $data): array
{ {
$chartData = [ return [
'count' => 1, 'count' => 1,
'labels' => array_keys($data), // take ALL labels from the first set. 'labels' => array_keys($data), // take ALL labels from the first set.
'datasets' => [ 'datasets' => [
@@ -219,7 +219,5 @@ class ChartJsGenerator implements GeneratorInterface
], ],
], ],
]; ];
return $chartData;
} }
} }

View File

@@ -41,12 +41,9 @@ use Throwable;
*/ */
class MonthReportGenerator implements ReportGeneratorInterface class MonthReportGenerator implements ReportGeneratorInterface
{ {
/** @var Collection The accounts used. */ private Collection $accounts;
private $accounts; private Carbon $end;
/** @var Carbon End date of the report. */ private Carbon $start;
private $end;
/** @var Carbon Start date of the report. */
private $start;
/** /**
* Generates the report. * Generates the report.
@@ -155,7 +152,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
} }
$locale = app('steam')->getLocale(); $locale = app('steam')->getLocale();
$return = [ return [
'journals' => $journals, 'journals' => $journals,
'currency' => $currency, 'currency' => $currency,
'exists' => count($journals) > 0, 'exists' => count($journals) > 0,
@@ -164,8 +161,6 @@ class MonthReportGenerator implements ReportGeneratorInterface
'dayBefore' => $date->formatLocalized((string) trans('config.month_and_day', [], $locale)), 'dayBefore' => $date->formatLocalized((string) trans('config.month_and_day', [], $locale)),
'dayBeforeBalance' => $dayBeforeBalance, 'dayBeforeBalance' => $dayBeforeBalance,
]; ];
return $return;
} }
/** /**

View File

@@ -50,11 +50,9 @@ class ConfigurationRequest extends LoggedInRequest
public function rules(): array public function rules(): array
{ {
// fixed // fixed
$rules = [ return [
'single_user_mode' => 'between:0,1|numeric', 'single_user_mode' => 'between:0,1|numeric',
'is_demo_site' => 'between:0,1|numeric', 'is_demo_site' => 'between:0,1|numeric',
]; ];
return $rules;
} }
} }

View File

@@ -46,13 +46,11 @@ class LinkTypeFormRequest extends LoggedInRequest
$nameRule = 'required|min:1'; $nameRule = 'required|min:1';
} }
$rules = [ return [
'id' => $idRule, 'id' => $idRule,
'name' => $nameRule, 'name' => $nameRule,
'inward' => 'required|min:1|different:outward', 'inward' => 'required|min:1|different:outward',
'outward' => 'required|min:1|different:inward', 'outward' => 'required|min:1|different:inward',
]; ];
return $rules;
} }
} }

View File

@@ -41,7 +41,7 @@ class RuleFormRequest extends LoggedInRequest
*/ */
public function getRuleData(): array public function getRuleData(): array
{ {
$data = [ return [
'title' => $this->string('title'), 'title' => $this->string('title'),
'rule_group_id' => $this->integer('rule_group_id'), 'rule_group_id' => $this->integer('rule_group_id'),
'active' => $this->boolean('active'), 'active' => $this->boolean('active'),
@@ -52,8 +52,6 @@ class RuleFormRequest extends LoggedInRequest
'triggers' => $this->getRuleTriggerData(), 'triggers' => $this->getRuleTriggerData(),
'actions' => $this->getRuleActionData(), 'actions' => $this->getRuleActionData(),
]; ];
return $data;
} }
/** /**

View File

@@ -43,11 +43,9 @@ class TestRuleFormRequest extends LoggedInRequest
{ {
// fixed // fixed
$validTriggers = $this->getTriggers(); $validTriggers = $this->getTriggers();
$rules = [ return [
'rule-trigger.*' => 'required|min:1|in:' . implode(',', $validTriggers), 'rule-trigger.*' => 'required|min:1|in:' . implode(',', $validTriggers),
'rule-trigger-value.*' => 'required|min:1|ruleTriggerValue', 'rule-trigger-value.*' => 'required|min:1|ruleTriggerValue',
]; ];
return $rules;
} }
} }

View File

@@ -614,9 +614,7 @@ class AccountRepository implements AccountRepositoryInterface
{ {
/** @var AccountUpdateService $service */ /** @var AccountUpdateService $service */
$service = app(AccountUpdateService::class); $service = app(AccountUpdateService::class);
$account = $service->update($account, $data); return $service->update($account, $data);
return $account;
} }
/** /**
@@ -661,7 +659,7 @@ class AccountRepository implements AccountRepositoryInterface
/** @var Storage $disk */ /** @var Storage $disk */
$disk = Storage::disk('upload'); $disk = Storage::disk('upload');
$set = $set->each( return $set->each(
static function (Attachment $attachment) use ($disk) { static function (Attachment $attachment) use ($disk) {
$notes = $attachment->notes()->first(); $notes = $attachment->notes()->first();
$attachment->file_exists = $disk->exists($attachment->fileName()); $attachment->file_exists = $disk->exists($attachment->fileName());
@@ -670,8 +668,6 @@ class AccountRepository implements AccountRepositoryInterface
return $attachment; return $attachment;
} }
); );
return $set;
} }
/** /**

View File

@@ -140,13 +140,10 @@ class BillRepository implements BillRepositoryInterface
*/ */
public function getActiveBills(): Collection public function getActiveBills(): Collection
{ {
/** @var Collection $set */ return $this->user->bills()
$set = $this->user->bills()
->where('active', 1) ->where('active', 1)
->orderBy('bills.name', 'ASC') ->orderBy('bills.name', 'ASC')
->get(['bills.*', DB::raw('((bills.amount_min + bills.amount_max) / 2) AS expectedAmount'),]); ->get(['bills.*', DB::raw('((bills.amount_min + bills.amount_max) / 2) AS expectedAmount'),]);
return $set;
} }
/** /**
@@ -163,7 +160,7 @@ class BillRepository implements BillRepositoryInterface
/** @var Storage $disk */ /** @var Storage $disk */
$disk = Storage::disk('upload'); $disk = Storage::disk('upload');
$set = $set->each( return $set->each(
static function (Attachment $attachment) use ($disk) { static function (Attachment $attachment) use ($disk) {
$notes = $attachment->notes()->first(); $notes = $attachment->notes()->first();
$attachment->file_exists = $disk->exists($attachment->fileName()); $attachment->file_exists = $disk->exists($attachment->fileName());
@@ -172,8 +169,6 @@ class BillRepository implements BillRepositoryInterface
return $attachment; return $attachment;
} }
); );
return $set;
} }
/** /**
@@ -198,7 +193,7 @@ class BillRepository implements BillRepositoryInterface
$fields = ['bills.id', 'bills.created_at', 'bills.updated_at', 'bills.deleted_at', 'bills.user_id', 'bills.name', 'bills.amount_min', $fields = ['bills.id', 'bills.created_at', 'bills.updated_at', 'bills.deleted_at', 'bills.user_id', 'bills.name', 'bills.amount_min',
'bills.amount_max', 'bills.date', 'bills.transaction_currency_id', 'bills.repeat_freq', 'bills.skip', 'bills.automatch', 'bills.active',]; 'bills.amount_max', 'bills.date', 'bills.transaction_currency_id', 'bills.repeat_freq', 'bills.skip', 'bills.automatch', 'bills.active',];
$ids = $accounts->pluck('id')->toArray(); $ids = $accounts->pluck('id')->toArray();
$set = $this->user->bills() return $this->user->bills()
->leftJoin( ->leftJoin(
'transaction_journals', 'transaction_journals',
static function (JoinClause $join) { static function (JoinClause $join) {
@@ -217,7 +212,6 @@ class BillRepository implements BillRepositoryInterface
->orderBy('bills.name', 'ASC') ->orderBy('bills.name', 'ASC')
->groupBy($fields) ->groupBy($fields)
->get($fields); ->get($fields);
return $set;
} }
/** /**

View File

@@ -148,13 +148,11 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface
{ {
// both are NULL: // both are NULL:
if (null === $start && null === $end) { if (null === $start && null === $end) {
$set = BudgetLimit::leftJoin('budgets', 'budgets.id', '=', 'budget_limits.budget_id') return BudgetLimit::leftJoin('budgets', 'budgets.id', '=', 'budget_limits.budget_id')
->with(['budget']) ->with(['budget'])
->where('budgets.user_id', $this->user->id) ->where('budgets.user_id', $this->user->id)
->whereNull('budgets.deleted_at') ->whereNull('budgets.deleted_at')
->get(['budget_limits.*']); ->get(['budget_limits.*']);
return $set;
} }
// one of the two is NULL. // one of the two is NULL.
if (null === $start xor null === $end) { if (null === $start xor null === $end) {
@@ -170,12 +168,10 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface
// start date must be after $start. // start date must be after $start.
$query->where('start_date', '>=', $start->format('Y-m-d 00:00:00')); $query->where('start_date', '>=', $start->format('Y-m-d 00:00:00'));
} }
$set = $query->get(['budget_limits.*']); return $query->get(['budget_limits.*']);
return $set;
} }
// neither are NULL: // neither are NULL:
$set = BudgetLimit::leftJoin('budgets', 'budgets.id', '=', 'budget_limits.budget_id') return BudgetLimit::leftJoin('budgets', 'budgets.id', '=', 'budget_limits.budget_id')
->with(['budget']) ->with(['budget'])
->where('budgets.user_id', $this->user->id) ->where('budgets.user_id', $this->user->id)
->whereNull('budgets.deleted_at') ->whereNull('budgets.deleted_at')
@@ -206,8 +202,6 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface
); );
} }
)->get(['budget_limits.*']); )->get(['budget_limits.*']);
return $set;
} }
/** /**
@@ -250,13 +244,11 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface
// start date must be after $start. // start date must be after $start.
$query->where('start_date', '>=', $start->format('Y-m-d 00:00:00')); $query->where('start_date', '>=', $start->format('Y-m-d 00:00:00'));
} }
$set = $query->get(['budget_limits.*']); return $query->get(['budget_limits.*']);
return $set;
} }
// when both dates are set: // when both dates are set:
$set = $budget->budgetlimits() return $budget->budgetlimits()
->where( ->where(
static function (Builder $q5) use ($start, $end) { static function (Builder $q5) use ($start, $end) {
$q5->where( $q5->where(
@@ -286,8 +278,6 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface
); );
} }
)->orderBy('budget_limits.start_date', 'DESC')->get(['budget_limits.*']); )->orderBy('budget_limits.start_date', 'DESC')->get(['budget_limits.*']);
return $set;
} }
/** /**

View File

@@ -170,12 +170,10 @@ class BudgetRepository implements BudgetRepositoryInterface
*/ */
public function getActiveBudgets(): Collection public function getActiveBudgets(): Collection
{ {
/** @var Collection $set */ return $this->user->budgets()->where('active', 1)
$set = $this->user->budgets()->where('active', 1)
->orderBy('order', 'ASC') ->orderBy('order', 'ASC')
->orderBy('name', 'ASC') ->orderBy('name', 'ASC')
->get(); ->get();
return $set;
} }
/** /**
@@ -183,11 +181,8 @@ class BudgetRepository implements BudgetRepositoryInterface
*/ */
public function getBudgets(): Collection public function getBudgets(): Collection
{ {
/** @var Collection $set */ return $this->user->budgets()->orderBy('order', 'ASC')
$set = $this->user->budgets()->orderBy('order', 'ASC')
->orderBy('name', 'ASC')->get(); ->orderBy('name', 'ASC')->get();
return $set;
} }
/** /**
@@ -207,12 +202,9 @@ class BudgetRepository implements BudgetRepositoryInterface
*/ */
public function getInactiveBudgets(): Collection public function getInactiveBudgets(): Collection
{ {
/** @var Collection $set */ return $this->user->budgets()
$set = $this->user->budgets()
->orderBy('order', 'ASC') ->orderBy('order', 'ASC')
->orderBy('name', 'ASC')->where('active', 0)->get(); ->orderBy('name', 'ASC')->where('active', 0)->get();
return $set;
} }
/** /**
@@ -475,7 +467,7 @@ class BudgetRepository implements BudgetRepositoryInterface
/** @var Storage $disk */ /** @var Storage $disk */
$disk = Storage::disk('upload'); $disk = Storage::disk('upload');
$set = $set->each( return $set->each(
static function (Attachment $attachment) use ($disk) { static function (Attachment $attachment) use ($disk) {
$notes = $attachment->notes()->first(); $notes = $attachment->notes()->first();
$attachment->file_exists = $disk->exists($attachment->fileName()); $attachment->file_exists = $disk->exists($attachment->fileName());
@@ -484,8 +476,6 @@ class BudgetRepository implements BudgetRepositoryInterface
return $attachment; return $attachment;
} }
); );
return $set;
} }
public function getMaxOrder(): int public function getMaxOrder(): int

View File

@@ -168,10 +168,7 @@ class CategoryRepository implements CategoryRepositoryInterface
*/ */
public function getCategories(): Collection public function getCategories(): Collection
{ {
/** @var Collection $set */ return $this->user->categories()->with(['attachments'])->orderBy('name', 'ASC')->get();
$set = $this->user->categories()->with(['attachments'])->orderBy('name', 'ASC')->get();
return $set;
} }
/** /**
@@ -376,7 +373,7 @@ class CategoryRepository implements CategoryRepositoryInterface
/** @var Storage $disk */ /** @var Storage $disk */
$disk = Storage::disk('upload'); $disk = Storage::disk('upload');
$set = $set->each( return $set->each(
static function (Attachment $attachment) use ($disk) { static function (Attachment $attachment) use ($disk) {
$notes = $attachment->notes()->first(); $notes = $attachment->notes()->first();
$attachment->file_exists = $disk->exists($attachment->fileName()); $attachment->file_exists = $disk->exists($attachment->fileName());
@@ -385,7 +382,5 @@ class CategoryRepository implements CategoryRepositoryInterface
return $attachment; return $attachment;
} }
); );
return $set;
} }
} }

View File

@@ -312,9 +312,6 @@ class OperationsRepository implements OperationsRepositoryInterface
*/ */
private function getCategories(): Collection private function getCategories(): Collection
{ {
/** @var Collection $set */ return $this->user->categories()->get();
$set = $this->user->categories()->get();
return $set;
} }
} }

View File

@@ -58,10 +58,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
{ {
$count = $currency->transactions()->whereNull('deleted_at')->count() + $currency->transactionJournals()->whereNull('deleted_at')->count(); $count = $currency->transactions()->whereNull('deleted_at')->count() + $currency->transactionJournals()->whereNull('deleted_at')->count();
// also count foreign: // also count foreign:
$count += Transaction::where('foreign_currency_id', $currency->id)->count(); return $count + Transaction::where('foreign_currency_id', $currency->id)->count();
return $count;
} }
/** /**

View File

@@ -37,18 +37,7 @@ use Storage;
*/ */
class JournalAPIRepository implements JournalAPIRepositoryInterface class JournalAPIRepository implements JournalAPIRepositoryInterface
{ {
/** @var User */ private User $user;
private $user;
/**
* Constructor.
*/
public function __construct()
{
if ('testing' === config('app.env')) {
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', get_class($this)));
}
}
/** /**
* Returns transaction by ID. Used to validate attachments. * Returns transaction by ID. Used to validate attachments.
@@ -59,12 +48,10 @@ class JournalAPIRepository implements JournalAPIRepositoryInterface
*/ */
public function findTransaction(int $transactionId): ?Transaction public function findTransaction(int $transactionId): ?Transaction
{ {
$transaction = Transaction::leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id') return Transaction::leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
->where('transaction_journals.user_id', $this->user->id) ->where('transaction_journals.user_id', $this->user->id)
->where('transactions.id', $transactionId) ->where('transactions.id', $transactionId)
->first(['transactions.*']); ->first(['transactions.*']);
return $transaction;
} }
/** /**
@@ -81,7 +68,7 @@ class JournalAPIRepository implements JournalAPIRepositoryInterface
/** @var Storage $disk */ /** @var Storage $disk */
$disk = Storage::disk('upload'); $disk = Storage::disk('upload');
$set = $set->each( return $set->each(
static function (Attachment $attachment) use ($disk) { static function (Attachment $attachment) use ($disk) {
$notes = $attachment->notes()->first(); $notes = $attachment->notes()->first();
$attachment->file_exists = $disk->exists($attachment->fileName()); $attachment->file_exists = $disk->exists($attachment->fileName());
@@ -90,8 +77,6 @@ class JournalAPIRepository implements JournalAPIRepositoryInterface
return $attachment; return $attachment;
} }
); );
return $set;
} }
/** /**

View File

@@ -210,13 +210,11 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface
$inward = TransactionJournalLink::whereDestinationId($journal->id)->get(); $inward = TransactionJournalLink::whereDestinationId($journal->id)->get();
$merged = $outward->merge($inward); $merged = $outward->merge($inward);
$filtered = $merged->filter( return $merged->filter(
function (TransactionJournalLink $link) { function (TransactionJournalLink $link) {
return (null !== $link->source && null !== $link->destination); return (null !== $link->source && null !== $link->destination);
} }
); );
return $filtered;
} }
/** /**

View File

@@ -161,10 +161,7 @@ trait ModifiesPiggyBanks
if (0 === bccomp('0', $amount)) { if (0 === bccomp('0', $amount)) {
return new PiggyBankEvent; return new PiggyBankEvent;
} }
/** @var PiggyBankEvent $event */ return PiggyBankEvent::create(['date' => Carbon::now(), 'amount' => $amount, 'piggy_bank_id' => $piggyBank->id]);
$event = PiggyBankEvent::create(['date' => Carbon::now(), 'amount' => $amount, 'piggy_bank_id' => $piggyBank->id]);
return $event;
} }
/** /**
@@ -176,16 +173,13 @@ trait ModifiesPiggyBanks
*/ */
public function createEventWithJournal(PiggyBank $piggyBank, string $amount, TransactionJournal $journal): PiggyBankEvent public function createEventWithJournal(PiggyBank $piggyBank, string $amount, TransactionJournal $journal): PiggyBankEvent
{ {
/** @var PiggyBankEvent $event */ return PiggyBankEvent::create(
$event = PiggyBankEvent::create(
[ [
'piggy_bank_id' => $piggyBank->id, 'piggy_bank_id' => $piggyBank->id,
'transaction_journal_id' => $journal->id, 'transaction_journal_id' => $journal->id,
'date' => $journal->date->format('Y-m-d'), 'date' => $journal->date->format('Y-m-d'),
'amount' => $amount] 'amount' => $amount]
); );
return $event;
} }
/** /**

View File

@@ -44,19 +44,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
{ {
use ModifiesPiggyBanks; use ModifiesPiggyBanks;
/** @var User */ private User $user;
private $user;
/**
* Constructor.
*/
public function __construct()
{
if ('testing' === config('app.env')) {
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', get_class($this)));
}
}
/** /**
* Find by name or return NULL. * Find by name or return NULL.
@@ -384,7 +372,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
/** @var Storage $disk */ /** @var Storage $disk */
$disk = Storage::disk('upload'); $disk = Storage::disk('upload');
$set = $set->each( return $set->each(
static function (Attachment $attachment) use ($disk) { static function (Attachment $attachment) use ($disk) {
$notes = $attachment->notes()->first(); $notes = $attachment->notes()->first();
$attachment->file_exists = $disk->exists($attachment->fileName()); $attachment->file_exists = $disk->exists($attachment->fileName());
@@ -393,8 +381,6 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
return $attachment; return $attachment;
} }
); );
return $set;
} }

View File

@@ -53,18 +53,8 @@ use Log;
class RecurringRepository implements RecurringRepositoryInterface class RecurringRepository implements RecurringRepositoryInterface
{ {
use CalculateRangeOccurrences, CalculateXOccurrences, CalculateXOccurrencesSince, FiltersWeekends; use CalculateRangeOccurrences, CalculateXOccurrences, CalculateXOccurrencesSince, FiltersWeekends;
/** @var User */ private User $user;
private $user;
/**
* Constructor.
*/
public function __construct()
{
if ('testing' === config('app.env')) {
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', get_class($this)));
}
}
/** /**
* Destroy a recurring transaction. * Destroy a recurring transaction.
@@ -246,9 +236,7 @@ class RecurringRepository implements RecurringRepositoryInterface
// filter out all the weekend days: // filter out all the weekend days:
$occurrences = $this->filterWeekends($repetition, $occurrences); return $this->filterWeekends($repetition, $occurrences);
return $occurrences;
} }
/** /**
@@ -386,9 +374,7 @@ class RecurringRepository implements RecurringRepositoryInterface
} }
// filter out all the weekend days: // filter out all the weekend days:
$occurrences = $this->filterWeekends($repetition, $occurrences); return $this->filterWeekends($repetition, $occurrences);
return $occurrences;
} }
/** /**
@@ -536,9 +522,7 @@ class RecurringRepository implements RecurringRepositoryInterface
// filter out everything if "repeat_until" is set. // filter out everything if "repeat_until" is set.
$repeatUntil = $repetition->recurrence->repeat_until; $repeatUntil = $repetition->recurrence->repeat_until;
$occurrences = $this->filterMaxDate($repeatUntil, $occurrences); return $this->filterMaxDate($repeatUntil, $occurrences);
return $occurrences;
} }
/** /**

View File

@@ -156,10 +156,7 @@ class TagRepository implements TagRepositoryInterface
*/ */
public function get(): Collection public function get(): Collection
{ {
/** @var Collection $tags */ return $this->user->tags()->orderBy('tag', 'ASC')->get();
$tags = $this->user->tags()->orderBy('tag', 'ASC')->get();
return $tags;
} }
/** /**
@@ -575,7 +572,7 @@ class TagRepository implements TagRepositoryInterface
/** @var Storage $disk */ /** @var Storage $disk */
$disk = Storage::disk('upload'); $disk = Storage::disk('upload');
$set = $set->each( return $set->each(
static function (Attachment $attachment) use ($disk) { static function (Attachment $attachment) use ($disk) {
$notes = $attachment->notes()->first(); $notes = $attachment->notes()->first();
$attachment->file_exists = $disk->exists($attachment->fileName()); $attachment->file_exists = $disk->exists($attachment->fileName());
@@ -584,8 +581,6 @@ class TagRepository implements TagRepositoryInterface
return $attachment; return $attachment;
} }
); );
return $set;
} }
/** /**

View File

@@ -229,8 +229,6 @@ class IsValidAttachmentModel implements Rule
$replace = ''; $replace = '';
$model = str_replace($search, $replace, $model); $model = str_replace($search, $replace, $model);
$model = sprintf('FireflyIII\Models\%s', $model); return sprintf('FireflyIII\Models\%s', $model);
return $model;
} }
} }

View File

@@ -109,9 +109,7 @@ trait JournalServiceTrait
$result = $this->findAccountByName($result, $data, $expectedTypes[$transactionType]); $result = $this->findAccountByName($result, $data, $expectedTypes[$transactionType]);
$result = $this->findAccountByIban($result, $data, $expectedTypes[$transactionType]); $result = $this->findAccountByIban($result, $data, $expectedTypes[$transactionType]);
$result = $this->createAccount($result, $data, $expectedTypes[$transactionType][0]); $result = $this->createAccount($result, $data, $expectedTypes[$transactionType][0]);
$result = $this->getCashAccount($result, $data, $expectedTypes[$transactionType]); return $this->getCashAccount($result, $data, $expectedTypes[$transactionType]);
return $result;
} }
/** /**

View File

@@ -41,9 +41,7 @@ trait BasicDataSupport
*/ */
protected function isInArray(array $array, int $entryId) // helper for data (math, calculations) protected function isInArray(array $array, int $entryId) // helper for data (math, calculations)
{ {
$result = $array[$entryId] ?? '0'; return $array[$entryId] ?? '0';
return $result;
} }

View File

@@ -50,9 +50,7 @@ trait DateCalculation
if ($start->lte($today) && $end->gte($today)) { if ($start->lte($today) && $end->gte($today)) {
$difference = $today->diffInDays($end); $difference = $today->diffInDays($end);
} }
$difference = 0 === $difference ? 1 : $difference; return 0 === $difference ? 1 : $difference;
return $difference;
} }
/** /**

View File

@@ -51,9 +51,7 @@ trait GetConfigurationData
E_ALL & ~E_NOTICE & ~E_STRICT => 'E_ALL & ~E_NOTICE & ~E_STRICT', E_ALL & ~E_NOTICE & ~E_STRICT => 'E_ALL & ~E_NOTICE & ~E_STRICT',
E_COMPILE_ERROR | E_RECOVERABLE_ERROR | E_ERROR | E_CORE_ERROR => 'E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR', E_COMPILE_ERROR | E_RECOVERABLE_ERROR | E_ERROR | E_CORE_ERROR => 'E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR',
]; ];
$result = $array[$value] ?? (string)$value; return $array[$value] ?? (string)$value;
return $result;
} }
/** /**
@@ -150,7 +148,7 @@ trait GetConfigurationData
$index = (string)trans('firefly.everything'); $index = (string)trans('firefly.everything');
$ranges[$index] = [$first, new Carbon]; $ranges[$index] = [$first, new Carbon];
$return = [ return [
'title' => $title, 'title' => $title,
'configuration' => [ 'configuration' => [
'apply' => (string)trans('firefly.apply'), 'apply' => (string)trans('firefly.apply'),
@@ -163,8 +161,6 @@ trait GetConfigurationData
'ranges' => $ranges, 'ranges' => $ranges,
], ],
]; ];
return $return;
} }
/** /**

View File

@@ -98,9 +98,7 @@ trait RequestInformation
// also check cache first: // also check cache first:
if ($help->inCache($route, $language)) { if ($help->inCache($route, $language)) {
Log::debug(sprintf('Help text %s was in cache.', $language)); Log::debug(sprintf('Help text %s was in cache.', $language));
$content = $help->getFromCache($route, $language); return $help->getFromCache($route, $language);
return $content;
} }
$baseHref = route('index'); $baseHref = route('index');
$helpString = sprintf( $helpString = sprintf(

View File

@@ -45,12 +45,7 @@ class Preferences
*/ */
public function beginsWith(User $user, string $search): Collection public function beginsWith(User $user, string $search): Collection
{ {
if ('testing' === config('app.env')) { return Preference::where('user_id', $user->id)->where('name', 'LIKE', $search . '%')->get();
Log::warning(sprintf('%s should NOT be called in the TEST environment!', __METHOD__));
}
$set = Preference::where('user_id', $user->id)->where('name', 'LIKE', $search . '%')->get();
return $set;
} }
/** /**
@@ -60,9 +55,6 @@ class Preferences
*/ */
public function delete(string $name): bool public function delete(string $name): bool
{ {
if ('testing' === config('app.env')) {
Log::warning(sprintf('%s should NOT be called in the TEST environment!', __METHOD__));
}
$fullName = sprintf('preference%s%s', auth()->user()->id, $name); $fullName = sprintf('preference%s%s', auth()->user()->id, $name);
if (Cache::has($fullName)) { if (Cache::has($fullName)) {
Cache::forget($fullName); Cache::forget($fullName);

View File

@@ -540,9 +540,7 @@ class Steam
if (null === $amount) { if (null === $amount) {
return null; return null;
} }
$amount = bcmul($amount, '-1'); return bcmul($amount, '-1');
return $amount;
} }
/** /**

View File

@@ -121,8 +121,7 @@ class Breadcrumbs extends AbstractExtension
} }
$html .= sprintf('<li class="%1$s"><a href="%2$s" title="%3$s">%3$s</a></li>', $class, $route, trans($breadcrumb['title'])); $html .= sprintf('<li class="%1$s"><a href="%2$s" title="%3$s">%3$s</a></li>', $class, $route, trans($breadcrumb['title']));
} }
$html .= '</ol>';
return $html; return $html . '</ol>';
} }
} }

View File

@@ -116,9 +116,7 @@ class SearchRuleEngine implements RuleEngineInterface
} }
$collection = $collection->merge($found); $collection = $collection->merge($found);
} }
$collection = $collection->unique(); return $collection->unique();
return $collection;
} }
/** /**

View File

@@ -47,9 +47,6 @@ class BillTransformer extends AbstractTransformer
public function __construct() public function __construct()
{ {
$this->repository = app(BillRepositoryInterface::class); $this->repository = app(BillRepositoryInterface::class);
if ('testing' === config('app.env')) {
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', get_class($this)));
}
} }
/** /**
@@ -80,7 +77,7 @@ class BillTransformer extends AbstractTransformer
$objectGroupTitle = $objectGroup->title; $objectGroupTitle = $objectGroup->title;
} }
$data = [ return [
'id' => (int)$bill->id, 'id' => (int)$bill->id,
'created_at' => $bill->created_at->toAtomString(), 'created_at' => $bill->created_at->toAtomString(),
'updated_at' => $bill->updated_at->toAtomString(), 'updated_at' => $bill->updated_at->toAtomString(),
@@ -110,9 +107,6 @@ class BillTransformer extends AbstractTransformer
], ],
], ],
]; ];
return $data;
} }
/** /**

View File

@@ -31,18 +31,6 @@ use Log;
*/ */
class BudgetLimitTransformer extends AbstractTransformer class BudgetLimitTransformer extends AbstractTransformer
{ {
/**
* CurrencyTransformer constructor.
*
* @codeCoverageIgnore
*/
public function __construct()
{
if ('testing' === config('app.env')) {
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', get_class($this)));
}
}
/** /**
* Transform the note. * Transform the note.
* *
@@ -68,7 +56,7 @@ class BudgetLimitTransformer extends AbstractTransformer
$currencyDecimalPlaces = $currency->decimal_places; $currencyDecimalPlaces = $currency->decimal_places;
} }
$amount = number_format((float) $amount, $currencyDecimalPlaces, '.', ''); $amount = number_format((float) $amount, $currencyDecimalPlaces, '.', '');
$data = [ return [
'id' => (int) $budgetLimit->id, 'id' => (int) $budgetLimit->id,
'created_at' => $budgetLimit->created_at->toAtomString(), 'created_at' => $budgetLimit->created_at->toAtomString(),
'updated_at' => $budgetLimit->updated_at->toAtomString(), 'updated_at' => $budgetLimit->updated_at->toAtomString(),
@@ -88,7 +76,5 @@ class BudgetLimitTransformer extends AbstractTransformer
], ],
], ],
]; ];
return $data;
} }
} }

View File

@@ -50,9 +50,6 @@ class BudgetTransformer extends AbstractTransformer
{ {
$this->opsRepository = app(OperationsRepositoryInterface::class); $this->opsRepository = app(OperationsRepositoryInterface::class);
$this->repository = app(BudgetRepositoryInterface::class); $this->repository = app(BudgetRepositoryInterface::class);
if ('testing' === config('app.env')) {
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', get_class($this)));
}
} }
/** /**
@@ -92,7 +89,7 @@ class BudgetTransformer extends AbstractTransformer
$abPeriod = $autoBudget->period; $abPeriod = $autoBudget->period;
} }
$data = [ return [
'id' => (int)$budget->id, 'id' => (int)$budget->id,
'created_at' => $budget->created_at->toAtomString(), 'created_at' => $budget->created_at->toAtomString(),
'updated_at' => $budget->updated_at->toAtomString(), 'updated_at' => $budget->updated_at->toAtomString(),
@@ -111,8 +108,6 @@ class BudgetTransformer extends AbstractTransformer
], ],
], ],
]; ];
return $data;
} }
/** /**

View File

@@ -45,9 +45,6 @@ class CategoryTransformer extends AbstractTransformer
public function __construct() public function __construct()
{ {
$this->opsRepository = app(OperationsRepositoryInterface::class); $this->opsRepository = app(OperationsRepositoryInterface::class);
if ('testing' === config('app.env')) {
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', get_class($this)));
}
} }
/** /**
@@ -69,7 +66,7 @@ class CategoryTransformer extends AbstractTransformer
$earned = $this->beautify($this->opsRepository->sumIncome($start, $end, null, new Collection([$category]))); $earned = $this->beautify($this->opsRepository->sumIncome($start, $end, null, new Collection([$category])));
$spent = $this->beautify($this->opsRepository->sumExpenses($start, $end, null, new Collection([$category]))); $spent = $this->beautify($this->opsRepository->sumExpenses($start, $end, null, new Collection([$category])));
} }
$data = [ return [
'id' => (int)$category->id, 'id' => (int)$category->id,
'created_at' => $category->created_at->toAtomString(), 'created_at' => $category->created_at->toAtomString(),
'updated_at' => $category->updated_at->toAtomString(), 'updated_at' => $category->updated_at->toAtomString(),
@@ -83,8 +80,6 @@ class CategoryTransformer extends AbstractTransformer
], ],
], ],
]; ];
return $data;
} }
/** /**

View File

@@ -32,19 +32,6 @@ use Log;
*/ */
class CurrencyExchangeRateTransformer extends AbstractTransformer class CurrencyExchangeRateTransformer extends AbstractTransformer
{ {
/**
* PiggyBankEventTransformer constructor.
*
* @codeCoverageIgnore
*/
public function __construct()
{
if ('testing' === config('app.env')) {
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', get_class($this)));
}
}
/** /**
* @param CurrencyExchangeRate $rate * @param CurrencyExchangeRate $rate
* *
@@ -54,7 +41,7 @@ class CurrencyExchangeRateTransformer extends AbstractTransformer
{ {
$result = number_format((float) $rate->rate * (float) $this->parameters->get('amount'), $rate->toCurrency->decimal_places, '.', ''); $result = number_format((float) $rate->rate * (float) $this->parameters->get('amount'), $rate->toCurrency->decimal_places, '.', '');
$result = 0.0 === $result ? null : $result; $result = 0.0 === $result ? null : $result;
$data = [ return [
'id' => (int)$rate->id, 'id' => (int)$rate->id,
'created_at' => $rate->created_at->toAtomString(), 'created_at' => $rate->created_at->toAtomString(),
'updated_at' => $rate->updated_at->toAtomString(), 'updated_at' => $rate->updated_at->toAtomString(),
@@ -78,7 +65,5 @@ class CurrencyExchangeRateTransformer extends AbstractTransformer
], ],
], ],
]; ];
return $data;
} }
} }

View File

@@ -31,17 +31,6 @@ use Log;
*/ */
class CurrencyTransformer extends AbstractTransformer class CurrencyTransformer extends AbstractTransformer
{ {
/**
* CurrencyTransformer constructor.
*
* @codeCoverageIgnore
*/
public function __construct()
{
if ('testing' === config('app.env')) {
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', get_class($this)));
}
}
/** /**
* Transform the currency. * Transform the currency.
@@ -57,7 +46,7 @@ class CurrencyTransformer extends AbstractTransformer
if (null !== $defaultCurrency) { if (null !== $defaultCurrency) {
$isDefault = (int) $defaultCurrency->id === (int) $currency->id; $isDefault = (int) $defaultCurrency->id === (int) $currency->id;
} }
$data = [ return [
'id' => (int) $currency->id, 'id' => (int) $currency->id,
'created_at' => $currency->created_at->toAtomString(), 'created_at' => $currency->created_at->toAtomString(),
'updated_at' => $currency->updated_at->toAtomString(), 'updated_at' => $currency->updated_at->toAtomString(),
@@ -74,7 +63,5 @@ class CurrencyTransformer extends AbstractTransformer
], ],
], ],
]; ];
return $data;
} }
} }

View File

@@ -33,18 +33,6 @@ use Log;
*/ */
class LinkTypeTransformer extends AbstractTransformer class LinkTypeTransformer extends AbstractTransformer
{ {
/**
* CurrencyTransformer constructor.
*
* @codeCoverageIgnore
*/
public function __construct()
{
if ('testing' === config('app.env')) {
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', get_class($this)));
}
}
/** /**
* Transform the currency. * Transform the currency.
* *
@@ -54,7 +42,7 @@ class LinkTypeTransformer extends AbstractTransformer
*/ */
public function transform(LinkType $linkType): array public function transform(LinkType $linkType): array
{ {
$data = [ return [
'id' => (int)$linkType->id, 'id' => (int)$linkType->id,
'created_at' => $linkType->created_at->toAtomString(), 'created_at' => $linkType->created_at->toAtomString(),
'updated_at' => $linkType->updated_at->toAtomString(), 'updated_at' => $linkType->updated_at->toAtomString(),
@@ -69,7 +57,5 @@ class LinkTypeTransformer extends AbstractTransformer
], ],
], ],
]; ];
return $data;
} }
} }

View File

@@ -52,9 +52,6 @@ class PiggyBankEventTransformer extends AbstractTransformer
$this->repository = app(AccountRepositoryInterface::class); $this->repository = app(AccountRepositoryInterface::class);
$this->currencyRepos = app(CurrencyRepositoryInterface::class); $this->currencyRepos = app(CurrencyRepositoryInterface::class);
$this->piggyRepos = app(PiggyBankRepositoryInterface::class); $this->piggyRepos = app(PiggyBankRepositoryInterface::class);
if ('testing' === config('app.env')) {
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', get_class($this)));
}
} }
/** /**
@@ -84,7 +81,7 @@ class PiggyBankEventTransformer extends AbstractTransformer
$groupId = (int) $event->transactionJournal->transaction_group_id; $groupId = (int) $event->transactionJournal->transaction_group_id;
$journalId = (int) $journalId; $journalId = (int) $journalId;
} }
$data = [ return [
'id' => (int) $event->id, 'id' => (int) $event->id,
'created_at' => $event->created_at->toAtomString(), 'created_at' => $event->created_at->toAtomString(),
'updated_at' => $event->updated_at->toAtomString(), 'updated_at' => $event->updated_at->toAtomString(),
@@ -102,8 +99,6 @@ class PiggyBankEventTransformer extends AbstractTransformer
], ],
], ],
]; ];
return $data;
} }
} }

View File

@@ -54,9 +54,6 @@ class PiggyBankTransformer extends AbstractTransformer
$this->accountRepos = app(AccountRepositoryInterface::class); $this->accountRepos = app(AccountRepositoryInterface::class);
$this->currencyRepos = app(CurrencyRepositoryInterface::class); $this->currencyRepos = app(CurrencyRepositoryInterface::class);
$this->piggyRepos = app(PiggyBankRepositoryInterface::class); $this->piggyRepos = app(PiggyBankRepositoryInterface::class);
if ('testing' === config('app.env')) {
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', get_class($this)));
}
} }
@@ -108,7 +105,7 @@ class PiggyBankTransformer extends AbstractTransformer
$targetAmount = $piggyBank->targetamount; $targetAmount = $piggyBank->targetamount;
$targetAmount = 1 === bccomp('0.01', (string) $targetAmount) ? '0.01' : $targetAmount; $targetAmount = 1 === bccomp('0.01', (string) $targetAmount) ? '0.01' : $targetAmount;
$percentage = (int) (0 !== bccomp('0', $currentAmountStr) ? $currentAmountStr / $targetAmount * 100 : 0); $percentage = (int) (0 !== bccomp('0', $currentAmountStr) ? $currentAmountStr / $targetAmount * 100 : 0);
$data = [ return [
'id' => (int) $piggyBank->id, 'id' => (int) $piggyBank->id,
'created_at' => $piggyBank->created_at->toAtomString(), 'created_at' => $piggyBank->created_at->toAtomString(),
'updated_at' => $piggyBank->updated_at->toAtomString(), 'updated_at' => $piggyBank->updated_at->toAtomString(),
@@ -139,7 +136,5 @@ class PiggyBankTransformer extends AbstractTransformer
], ],
], ],
]; ];
return $data;
} }
} }

View File

@@ -63,9 +63,6 @@ class RecurrenceTransformer extends AbstractTransformer
$this->factory = app(CategoryFactory::class); $this->factory = app(CategoryFactory::class);
$this->budgetRepos = app(BudgetRepositoryInterface::class); $this->budgetRepos = app(BudgetRepositoryInterface::class);
if ('testing' === config('app.env')) {
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', get_class($this)));
}
} }
/** /**
@@ -90,7 +87,7 @@ class RecurrenceTransformer extends AbstractTransformer
$reps = 0 === (int)$recurrence->repetitions ? null : (int)$recurrence->repetitions; $reps = 0 === (int)$recurrence->repetitions ? null : (int)$recurrence->repetitions;
Log::debug('Get basic data.'); Log::debug('Get basic data.');
// basic data. // basic data.
$return = [ return [
'id' => (int)$recurrence->id, 'id' => (int)$recurrence->id,
'created_at' => $recurrence->created_at->toAtomString(), 'created_at' => $recurrence->created_at->toAtomString(),
'updated_at' => $recurrence->updated_at->toAtomString(), 'updated_at' => $recurrence->updated_at->toAtomString(),
@@ -113,9 +110,6 @@ class RecurrenceTransformer extends AbstractTransformer
], ],
], ],
]; ];
return $return;
} }
/** /**

View File

@@ -31,17 +31,6 @@ use Log;
*/ */
class RuleGroupTransformer extends AbstractTransformer class RuleGroupTransformer extends AbstractTransformer
{ {
/**
* RuleGroupTransformer constructor.
*
* @codeCoverageIgnore
*/
public function __construct()
{
if ('testing' === config('app.env')) {
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', get_class($this)));
}
}
/** /**
* Transform the rule group * Transform the rule group
@@ -52,7 +41,7 @@ class RuleGroupTransformer extends AbstractTransformer
*/ */
public function transform(RuleGroup $ruleGroup): array public function transform(RuleGroup $ruleGroup): array
{ {
$data = [ return [
'id' => (int)$ruleGroup->id, 'id' => (int)$ruleGroup->id,
'created_at' => $ruleGroup->created_at->toAtomString(), 'created_at' => $ruleGroup->created_at->toAtomString(),
'updated_at' => $ruleGroup->updated_at->toAtomString(), 'updated_at' => $ruleGroup->updated_at->toAtomString(),
@@ -67,8 +56,6 @@ class RuleGroupTransformer extends AbstractTransformer
], ],
], ],
]; ];
return $data;
} }

View File

@@ -47,9 +47,6 @@ class RuleTransformer extends AbstractTransformer
public function __construct() public function __construct()
{ {
$this->ruleRepository = app(RuleRepositoryInterface::class); $this->ruleRepository = app(RuleRepositoryInterface::class);
if ('testing' === config('app.env')) {
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', get_class($this)));
}
} }
/** /**
@@ -64,7 +61,7 @@ class RuleTransformer extends AbstractTransformer
{ {
$this->ruleRepository->setUser($rule->user); $this->ruleRepository->setUser($rule->user);
$data = [ return [
'id' => (int)$rule->id, 'id' => (int)$rule->id,
'created_at' => $rule->created_at->toAtomString(), 'created_at' => $rule->created_at->toAtomString(),
'updated_at' => $rule->updated_at->toAtomString(), 'updated_at' => $rule->updated_at->toAtomString(),
@@ -85,8 +82,6 @@ class RuleTransformer extends AbstractTransformer
], ],
], ],
]; ];
return $data;
} }
/** /**

View File

@@ -33,17 +33,6 @@ use Log;
*/ */
class TagTransformer extends AbstractTransformer class TagTransformer extends AbstractTransformer
{ {
/**
* TagTransformer constructor.
*
* @codeCoverageIgnore
*/
public function __construct()
{
if ('testing' === config('app.env')) {
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', get_class($this)));
}
}
/** /**
* Transform a tag. * Transform a tag.
@@ -67,7 +56,7 @@ class TagTransformer extends AbstractTransformer
$longitude = $location->longitude; $longitude = $location->longitude;
$zoomLevel = $location->zoom_level; $zoomLevel = $location->zoom_level;
} }
$data = [ return [
'id' => (int)$tag->id, 'id' => (int)$tag->id,
'created_at' => $tag->created_at->toAtomString(), 'created_at' => $tag->created_at->toAtomString(),
'updated_at' => $tag->updated_at->toAtomString(), 'updated_at' => $tag->updated_at->toAtomString(),
@@ -84,8 +73,6 @@ class TagTransformer extends AbstractTransformer
], ],
], ],
]; ];
return $data;
} }
} }

View File

@@ -76,7 +76,7 @@ class TransactionGroupTransformer extends AbstractTransformer
{ {
$data = new NullArrayObject($group); $data = new NullArrayObject($group);
$first = new NullArrayObject(reset($group['transactions'])); $first = new NullArrayObject(reset($group['transactions']));
$result = [ return [
'id' => (int) $first['transaction_group_id'], 'id' => (int) $first['transaction_group_id'],
'created_at' => $first['created_at']->toAtomString(), 'created_at' => $first['created_at']->toAtomString(),
'updated_at' => $first['updated_at']->toAtomString(), 'updated_at' => $first['updated_at']->toAtomString(),
@@ -90,10 +90,6 @@ class TransactionGroupTransformer extends AbstractTransformer
], ],
], ],
]; ];
// do something else.
return $result;
} }
/** /**

View File

@@ -45,10 +45,6 @@ class TransactionLinkTransformer extends AbstractTransformer
public function __construct() public function __construct()
{ {
$this->repository = app(JournalRepositoryInterface::class); $this->repository = app(JournalRepositoryInterface::class);
if ('testing' === config('app.env')) {
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', get_class($this)));
}
} }
/** /**
@@ -59,7 +55,7 @@ class TransactionLinkTransformer extends AbstractTransformer
public function transform(TransactionJournalLink $link): array public function transform(TransactionJournalLink $link): array
{ {
$notes = $this->repository->getLinkNoteText($link); $notes = $this->repository->getLinkNoteText($link);
$data = [ return [
'id' => (int)$link->id, 'id' => (int)$link->id,
'created_at' => $link->created_at->toAtomString(), 'created_at' => $link->created_at->toAtomString(),
'updated_at' => $link->updated_at->toAtomString(), 'updated_at' => $link->updated_at->toAtomString(),
@@ -74,7 +70,5 @@ class TransactionLinkTransformer extends AbstractTransformer
], ],
], ],
]; ];
return $data;
} }
} }

View File

@@ -134,9 +134,6 @@ trait DepositValidation
$account->accountType = $accountType; $account->accountType = $accountType;
$this->source = $account; $this->source = $account;
} }
$result = $result ?? false; return $result ?? false;
// don't expect to end up here:
return $result;
} }
} }

View File

@@ -143,8 +143,6 @@ trait OBValidation
$account->accountType = $accountType; $account->accountType = $accountType;
$this->source = $account; $this->source = $account;
} }
$result = $result ?? false; return $result ?? false;
return $result;
} }
} }