Various PSR12 code cleanup

This commit is contained in:
James Cole
2022-12-29 19:41:57 +01:00
parent 0022009dd5
commit dbf3e76ecc
340 changed files with 4079 additions and 3816 deletions

View File

@@ -1,4 +1,5 @@
<?php
/**
* ReportController.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -39,6 +40,8 @@ use Illuminate\Routing\Redirector;
use Illuminate\Support\Collection;
use Illuminate\View\View;
use Log;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
/**
* Class ReportController.
@@ -63,7 +66,7 @@ class ReportController extends Controller
$this->middleware(
function ($request, $next) {
app('view')->share('title', (string) trans('firefly.reports'));
app('view')->share('title', (string)trans('firefly.reports'));
app('view')->share('mainTitleIcon', 'fa-bar-chart');
app('view')->share('subTitleIcon', 'fa-calendar');
$this->helper = app(ReportHelperInterface::class);
@@ -77,9 +80,9 @@ class ReportController extends Controller
/**
* Show audit report.
*
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
*
* @return Factory|View|string
*
@@ -88,7 +91,7 @@ class ReportController extends Controller
public function auditReport(Collection $accounts, Carbon $start, Carbon $end)
{
if ($end < $start) {
return view('error')->with('message', (string) trans('firefly.end_after_start_date'));
return view('error')->with('message', (string)trans('firefly.end_after_start_date'));
}
$this->repository->cleanupBudgets();
@@ -112,10 +115,10 @@ class ReportController extends Controller
/**
* Show budget report.
*
* @param Collection $accounts
* @param Collection $budgets
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Collection $budgets
* @param Carbon $start
* @param Carbon $end
*
* @return Factory|View|string
*
@@ -124,7 +127,7 @@ class ReportController extends Controller
public function budgetReport(Collection $accounts, Collection $budgets, Carbon $start, Carbon $end)
{
if ($end < $start) {
return view('error')->with('message', (string) trans('firefly.end_after_start_date'));
return view('error')->with('message', (string)trans('firefly.end_after_start_date'));
}
$this->repository->cleanupBudgets();
@@ -149,10 +152,10 @@ class ReportController extends Controller
/**
* Show category report.
*
* @param Collection $accounts
* @param Collection $categories
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Collection $categories
* @param Carbon $start
* @param Carbon $end
*
* @return Factory|View|string
*
@@ -161,7 +164,7 @@ class ReportController extends Controller
public function categoryReport(Collection $accounts, Collection $categories, Carbon $start, Carbon $end)
{
if ($end < $start) {
return view('error')->with('message', (string) trans('firefly.end_after_start_date'));
return view('error')->with('message', (string)trans('firefly.end_after_start_date'));
}
$this->repository->cleanupBudgets();
@@ -186,9 +189,9 @@ class ReportController extends Controller
/**
* Show default report.
*
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
*
* @return Factory|View|string
*
@@ -197,7 +200,7 @@ class ReportController extends Controller
public function defaultReport(Collection $accounts, Carbon $start, Carbon $end)
{
if ($end < $start) {
return view('error')->with('message', (string) trans('firefly.end_after_start_date'));
return view('error')->with('message', (string)trans('firefly.end_after_start_date'));
}
$this->repository->cleanupBudgets();
@@ -222,10 +225,10 @@ class ReportController extends Controller
/**
* Show account report.
*
* @param Collection $accounts
* @param Collection $expense
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Collection $expense
* @param Carbon $start
* @param Carbon $end
*
* @return string
* @throws FireflyException
@@ -242,8 +245,10 @@ class ReportController extends Controller
'subTitle',
trans(
'firefly.report_double',
['start' => $start->isoFormat($this->monthAndDayFormat),
'end' => $end->isoFormat($this->monthAndDayFormat)]
[
'start' => $start->isoFormat($this->monthAndDayFormat),
'end' => $end->isoFormat($this->monthAndDayFormat),
]
)
);
@@ -257,12 +262,12 @@ class ReportController extends Controller
/**
* Show index.
*
* @param AccountRepositoryInterface $repository
* @param AccountRepositoryInterface $repository
*
* @return Factory|View
* @throws FireflyException
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function index(AccountRepositoryInterface $repository)
{
@@ -301,7 +306,7 @@ class ReportController extends Controller
/**
* Show options for reports.
*
* @param string $reportType
* @param string $reportType
*
* @return JsonResponse
*
@@ -322,7 +327,7 @@ class ReportController extends Controller
/**
* Process the submit of report.
*
* @param ReportFormRequest $request
* @param ReportFormRequest $request
*
* @return RedirectResponse|Redirector
*
@@ -343,37 +348,37 @@ class ReportController extends Controller
if (0 === $request->getAccountList()->count()) {
Log::debug('Account count is zero');
session()->flash('error', (string) trans('firefly.select_at_least_one_account'));
session()->flash('error', (string)trans('firefly.select_at_least_one_account'));
return redirect(route('reports.index'));
}
if ('category' === $reportType && 0 === $request->getCategoryList()->count()) {
session()->flash('error', (string) trans('firefly.select_at_least_one_category'));
session()->flash('error', (string)trans('firefly.select_at_least_one_category'));
return redirect(route('reports.index'));
}
if ('budget' === $reportType && 0 === $request->getBudgetList()->count()) {
session()->flash('error', (string) trans('firefly.select_at_least_one_budget'));
session()->flash('error', (string)trans('firefly.select_at_least_one_budget'));
return redirect(route('reports.index'));
}
if ('tag' === $reportType && 0 === $request->getTagList()->count()) {
session()->flash('error', (string) trans('firefly.select_at_least_one_tag'));
session()->flash('error', (string)trans('firefly.select_at_least_one_tag'));
return redirect(route('reports.index'));
}
if ('double' === $reportType && 0 === $request->getDoubleList()->count()) {
session()->flash('error', (string) trans('firefly.select_at_least_one_expense'));
session()->flash('error', (string)trans('firefly.select_at_least_one_expense'));
return redirect(route('reports.index'));
}
if ($request->getEndDate() < $request->getStartDate()) {
return view('error')->with('message', (string) trans('firefly.end_after_start_date'));
return view('error')->with('message', (string)trans('firefly.end_after_start_date'));
}
$url = match ($reportType) {
@@ -391,10 +396,10 @@ class ReportController extends Controller
/**
* Get a tag report.
*
* @param Collection $accounts
* @param Collection $tags
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Collection $tags
* @param Carbon $start
* @param Carbon $end
*
* @return Factory|View|string
* @throws FireflyException
@@ -402,7 +407,7 @@ class ReportController extends Controller
public function tagReport(Collection $accounts, Collection $tags, Carbon $start, Carbon $end)
{
if ($end < $start) {
return view('error')->with('message', (string) trans('firefly.end_after_start_date'));
return view('error')->with('message', (string)trans('firefly.end_after_start_date'));
}
$this->repository->cleanupBudgets();