Clean up code.

This commit is contained in:
James Cole 2020-10-23 19:11:25 +02:00
parent 0845e1cb7d
commit 8dbd785ab8
No known key found for this signature in database
GPG Key ID: B5669F9493CDE38D
57 changed files with 84 additions and 441 deletions

View File

@ -60,8 +60,10 @@ abstract class Controller extends BaseController
$language = app('steam')->getLanguage();
app()->setLocale($language);
}
return $next($request);
});
}
);
}
@ -73,7 +75,7 @@ abstract class Controller extends BaseController
private function getParameters(): ParameterBag
{
$bag = new ParameterBag;
$page = (int) request()->get('page');
$page = (int)request()->get('page');
if (0 === $page) {
$page = 1;
}
@ -100,7 +102,7 @@ abstract class Controller extends BaseController
foreach ($integers as $integer) {
$value = request()->query->get($integer);
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;
}
$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',
'notes' => 'min:0|max:65536',
];
$rules = Location::requestRules($rules);
return $rules;
return Location::requestRules($rules);
}
}

View File

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

View File

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

View File

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

View File

@ -40,21 +40,7 @@ class BillFactory
{
use BillServiceTrait, CreatesObjectGroups;
/** @var 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)));
}
}
private User $user;
/**
* @param array $data
@ -153,11 +139,7 @@ class BillFactory
*/
public function findByName(string $name): ?Bill
{
$query = sprintf('%%%s%%', $name);
/** @var Bill $first */
$first = $this->user->bills()->where('name', 'LIKE', $query)->first();
return $first;
return $this->user->bills()->where('name', 'LIKE', sprintf('%%%s%%', $name))->first();
}
/**

View File

@ -32,21 +32,7 @@ use Log;
*/
class BudgetFactory
{
/** @var 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)));
}
}
private User $user;
/**
* @param int|null $budgetId

View File

@ -35,21 +35,7 @@ use Log;
*/
class CategoryFactory
{
/** @var 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)));
}
}
private User $user;
/**
* @param string $name

View File

@ -37,18 +37,6 @@ use Log;
*/
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 PiggyBank|null $piggyBank

View File

@ -33,21 +33,7 @@ use Log;
*/
class PiggyBankFactory
{
/** @var 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)));
}
}
private User $user;
/**
* @param int|null $piggyBankId

View File

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

View File

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

View File

@ -50,11 +50,9 @@ class ConfigurationRequest extends LoggedInRequest
public function rules(): array
{
// fixed
$rules = [
return [
'single_user_mode' => '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';
}
$rules = [
return [
'id' => $idRule,
'name' => $nameRule,
'inward' => 'required|min:1|different:outward',
'outward' => 'required|min:1|different:inward',
];
return $rules;
}
}

View File

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

View File

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

View File

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

View File

@ -140,13 +140,10 @@ class BillRepository implements BillRepositoryInterface
*/
public function getActiveBills(): Collection
{
/** @var Collection $set */
$set = $this->user->bills()
return $this->user->bills()
->where('active', 1)
->orderBy('bills.name', 'ASC')
->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 */
$disk = Storage::disk('upload');
$set = $set->each(
return $set->each(
static function (Attachment $attachment) use ($disk) {
$notes = $attachment->notes()->first();
$attachment->file_exists = $disk->exists($attachment->fileName());
@ -172,8 +169,6 @@ class BillRepository implements BillRepositoryInterface
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',
'bills.amount_max', 'bills.date', 'bills.transaction_currency_id', 'bills.repeat_freq', 'bills.skip', 'bills.automatch', 'bills.active',];
$ids = $accounts->pluck('id')->toArray();
$set = $this->user->bills()
return $this->user->bills()
->leftJoin(
'transaction_journals',
static function (JoinClause $join) {
@ -217,7 +212,6 @@ class BillRepository implements BillRepositoryInterface
->orderBy('bills.name', 'ASC')
->groupBy($fields)
->get($fields);
return $set;
}
/**

View File

@ -148,13 +148,11 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface
{
// both are NULL:
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'])
->where('budgets.user_id', $this->user->id)
->whereNull('budgets.deleted_at')
->get(['budget_limits.*']);
return $set;
}
// one of the two is NULL.
if (null === $start xor null === $end) {
@ -170,12 +168,10 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface
// start date must be after $start.
$query->where('start_date', '>=', $start->format('Y-m-d 00:00:00'));
}
$set = $query->get(['budget_limits.*']);
return $set;
return $query->get(['budget_limits.*']);
}
// 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'])
->where('budgets.user_id', $this->user->id)
->whereNull('budgets.deleted_at')
@ -206,8 +202,6 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface
);
}
)->get(['budget_limits.*']);
return $set;
}
/**
@ -250,13 +244,11 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface
// start date must be after $start.
$query->where('start_date', '>=', $start->format('Y-m-d 00:00:00'));
}
$set = $query->get(['budget_limits.*']);
return $set;
return $query->get(['budget_limits.*']);
}
// when both dates are set:
$set = $budget->budgetlimits()
return $budget->budgetlimits()
->where(
static function (Builder $q5) use ($start, $end) {
$q5->where(
@ -286,8 +278,6 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface
);
}
)->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
{
/** @var Collection $set */
$set = $this->user->budgets()->where('active', 1)
return $this->user->budgets()->where('active', 1)
->orderBy('order', 'ASC')
->orderBy('name', 'ASC')
->get();
return $set;
}
/**
@ -183,11 +181,8 @@ class BudgetRepository implements BudgetRepositoryInterface
*/
public function getBudgets(): Collection
{
/** @var Collection $set */
$set = $this->user->budgets()->orderBy('order', 'ASC')
return $this->user->budgets()->orderBy('order', 'ASC')
->orderBy('name', 'ASC')->get();
return $set;
}
/**
@ -207,12 +202,9 @@ class BudgetRepository implements BudgetRepositoryInterface
*/
public function getInactiveBudgets(): Collection
{
/** @var Collection $set */
$set = $this->user->budgets()
return $this->user->budgets()
->orderBy('order', 'ASC')
->orderBy('name', 'ASC')->where('active', 0)->get();
return $set;
}
/**
@ -475,7 +467,7 @@ class BudgetRepository implements BudgetRepositoryInterface
/** @var Storage $disk */
$disk = Storage::disk('upload');
$set = $set->each(
return $set->each(
static function (Attachment $attachment) use ($disk) {
$notes = $attachment->notes()->first();
$attachment->file_exists = $disk->exists($attachment->fileName());
@ -484,8 +476,6 @@ class BudgetRepository implements BudgetRepositoryInterface
return $attachment;
}
);
return $set;
}
public function getMaxOrder(): int

View File

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

View File

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

View File

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

View File

@ -37,18 +37,7 @@ use Storage;
*/
class JournalAPIRepository implements JournalAPIRepositoryInterface
{
/** @var 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)));
}
}
private User $user;
/**
* Returns transaction by ID. Used to validate attachments.
@ -59,12 +48,10 @@ class JournalAPIRepository implements JournalAPIRepositoryInterface
*/
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('transactions.id', $transactionId)
->first(['transactions.*']);
return $transaction;
}
/**
@ -81,7 +68,7 @@ class JournalAPIRepository implements JournalAPIRepositoryInterface
/** @var Storage $disk */
$disk = Storage::disk('upload');
$set = $set->each(
return $set->each(
static function (Attachment $attachment) use ($disk) {
$notes = $attachment->notes()->first();
$attachment->file_exists = $disk->exists($attachment->fileName());
@ -90,8 +77,6 @@ class JournalAPIRepository implements JournalAPIRepositoryInterface
return $attachment;
}
);
return $set;
}
/**

View File

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

View File

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

View File

@ -44,19 +44,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
{
use ModifiesPiggyBanks;
/** @var 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)));
}
}
private User $user;
/**
* Find by name or return NULL.
@ -384,7 +372,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
/** @var Storage $disk */
$disk = Storage::disk('upload');
$set = $set->each(
return $set->each(
static function (Attachment $attachment) use ($disk) {
$notes = $attachment->notes()->first();
$attachment->file_exists = $disk->exists($attachment->fileName());
@ -393,8 +381,6 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
return $attachment;
}
);
return $set;
}

View File

@ -53,18 +53,8 @@ use Log;
class RecurringRepository implements RecurringRepositoryInterface
{
use CalculateRangeOccurrences, CalculateXOccurrences, CalculateXOccurrencesSince, FiltersWeekends;
/** @var User */
private $user;
private User $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.
@ -246,9 +236,7 @@ class RecurringRepository implements RecurringRepositoryInterface
// filter out all the weekend days:
$occurrences = $this->filterWeekends($repetition, $occurrences);
return $occurrences;
return $this->filterWeekends($repetition, $occurrences);
}
/**
@ -386,9 +374,7 @@ class RecurringRepository implements RecurringRepositoryInterface
}
// filter out all the weekend days:
$occurrences = $this->filterWeekends($repetition, $occurrences);
return $occurrences;
return $this->filterWeekends($repetition, $occurrences);
}
/**
@ -536,9 +522,7 @@ class RecurringRepository implements RecurringRepositoryInterface
// filter out everything if "repeat_until" is set.
$repeatUntil = $repetition->recurrence->repeat_until;
$occurrences = $this->filterMaxDate($repeatUntil, $occurrences);
return $occurrences;
return $this->filterMaxDate($repeatUntil, $occurrences);
}
/**

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -51,9 +51,7 @@ trait GetConfigurationData
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',
];
$result = $array[$value] ?? (string)$value;
return $result;
return $array[$value] ?? (string)$value;
}
/**
@ -150,7 +148,7 @@ trait GetConfigurationData
$index = (string)trans('firefly.everything');
$ranges[$index] = [$first, new Carbon];
$return = [
return [
'title' => $title,
'configuration' => [
'apply' => (string)trans('firefly.apply'),
@ -163,8 +161,6 @@ trait GetConfigurationData
'ranges' => $ranges,
],
];
return $return;
}
/**

View File

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

View File

@ -45,12 +45,7 @@ class Preferences
*/
public function beginsWith(User $user, string $search): Collection
{
if ('testing' === config('app.env')) {
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;
return Preference::where('user_id', $user->id)->where('name', 'LIKE', $search . '%')->get();
}
/**
@ -60,9 +55,6 @@ class Preferences
*/
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);
if (Cache::has($fullName)) {
Cache::forget($fullName);

View File

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

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 .= '</ol>';
return $html;
return $html . '</ol>';
}
}

View File

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

View File

@ -47,9 +47,6 @@ class BillTransformer extends AbstractTransformer
public function __construct()
{
$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;
}
$data = [
return [
'id' => (int)$bill->id,
'created_at' => $bill->created_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
{
/**
* 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.
*
@ -68,7 +56,7 @@ class BudgetLimitTransformer extends AbstractTransformer
$currencyDecimalPlaces = $currency->decimal_places;
}
$amount = number_format((float) $amount, $currencyDecimalPlaces, '.', '');
$data = [
return [
'id' => (int) $budgetLimit->id,
'created_at' => $budgetLimit->created_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->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;
}
$data = [
return [
'id' => (int)$budget->id,
'created_at' => $budget->created_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()
{
$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])));
$spent = $this->beautify($this->opsRepository->sumExpenses($start, $end, null, new Collection([$category])));
}
$data = [
return [
'id' => (int)$category->id,
'created_at' => $category->created_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
{
/**
* 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
*
@ -54,7 +41,7 @@ class CurrencyExchangeRateTransformer extends AbstractTransformer
{
$result = number_format((float) $rate->rate * (float) $this->parameters->get('amount'), $rate->toCurrency->decimal_places, '.', '');
$result = 0.0 === $result ? null : $result;
$data = [
return [
'id' => (int)$rate->id,
'created_at' => $rate->created_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
{
/**
* 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.
@ -57,7 +46,7 @@ class CurrencyTransformer extends AbstractTransformer
if (null !== $defaultCurrency) {
$isDefault = (int) $defaultCurrency->id === (int) $currency->id;
}
$data = [
return [
'id' => (int) $currency->id,
'created_at' => $currency->created_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
{
/**
* 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.
*
@ -54,7 +42,7 @@ class LinkTypeTransformer extends AbstractTransformer
*/
public function transform(LinkType $linkType): array
{
$data = [
return [
'id' => (int)$linkType->id,
'created_at' => $linkType->created_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->currencyRepos = app(CurrencyRepositoryInterface::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;
$journalId = (int) $journalId;
}
$data = [
return [
'id' => (int) $event->id,
'created_at' => $event->created_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->currencyRepos = app(CurrencyRepositoryInterface::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 = 1 === bccomp('0.01', (string) $targetAmount) ? '0.01' : $targetAmount;
$percentage = (int) (0 !== bccomp('0', $currentAmountStr) ? $currentAmountStr / $targetAmount * 100 : 0);
$data = [
return [
'id' => (int) $piggyBank->id,
'created_at' => $piggyBank->created_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->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;
Log::debug('Get basic data.');
// basic data.
$return = [
return [
'id' => (int)$recurrence->id,
'created_at' => $recurrence->created_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
{
/**
* 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
@ -52,7 +41,7 @@ class RuleGroupTransformer extends AbstractTransformer
*/
public function transform(RuleGroup $ruleGroup): array
{
$data = [
return [
'id' => (int)$ruleGroup->id,
'created_at' => $ruleGroup->created_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()
{
$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);
$data = [
return [
'id' => (int)$rule->id,
'created_at' => $rule->created_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
{
/**
* 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.
@ -67,7 +56,7 @@ class TagTransformer extends AbstractTransformer
$longitude = $location->longitude;
$zoomLevel = $location->zoom_level;
}
$data = [
return [
'id' => (int)$tag->id,
'created_at' => $tag->created_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);
$first = new NullArrayObject(reset($group['transactions']));
$result = [
return [
'id' => (int) $first['transaction_group_id'],
'created_at' => $first['created_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()
{
$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
{
$notes = $this->repository->getLinkNoteText($link);
$data = [
return [
'id' => (int)$link->id,
'created_at' => $link->created_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;
$this->source = $account;
}
$result = $result ?? false;
// don't expect to end up here:
return $result;
return $result ?? false;
}
}

View File

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