From 02e14eb7237e4a083b610e1e91881ae151d34a47 Mon Sep 17 00:00:00 2001 From: philipp lang Date: Sat, 12 Feb 2022 16:44:43 +0100 Subject: [PATCH] Lint --- app/Member/Member.php | 2 +- app/Payment/ActionFactory.php | 9 +++------ app/Payment/SendpaymentController.php | 6 ++++++ app/Pdf/MemberPdfController.php | 4 ++++ app/Pdf/PdfRepositoryFactory.php | 8 +++++++- tests/Lib/TestsInertia.php | 13 +++++++++++++ 6 files changed, 34 insertions(+), 8 deletions(-) diff --git a/app/Member/Member.php b/app/Member/Member.php index 8c297cf6..4121944a 100644 --- a/app/Member/Member.php +++ b/app/Member/Member.php @@ -60,7 +60,7 @@ class Member extends Model } // ---------------------------------- Actions ---------------------------------- - public function syncVersion($api): void + public function syncVersion(Api $api): void { $version = $api->group($this->group->nami_id)->member($this->nami_id)->version; diff --git a/app/Payment/ActionFactory.php b/app/Payment/ActionFactory.php index d06eb8e0..31c793dd 100644 --- a/app/Payment/ActionFactory.php +++ b/app/Payment/ActionFactory.php @@ -3,6 +3,7 @@ namespace App\Payment; use App\Member\Member; +use App\Pdf\PdfRepository; use App\Pdf\PdfRepositoryFactory; use Illuminate\Support\Collection; @@ -11,9 +12,7 @@ class ActionFactory public function forMember(Member $member): Collection { - return app(PdfRepositoryFactory::class)->getTypes()->map(function(string $repo) use ($member) { - $repo = app($repo); - + return app(PdfRepositoryFactory::class)->getTypes()->map(function(PdfRepository $repo) use ($member): array { return [ 'href' => route('member.singlepdf', ['member' => $member, 'type' => get_class($repo)]), 'label' => $repo->linkLabel(), @@ -24,9 +23,7 @@ class ActionFactory public function allLinks(): Collection { - return app(PdfRepositoryFactory::class)->getTypes()->map(function(string $repo) { - $repo = app($repo); - + return app(PdfRepositoryFactory::class)->getTypes()->map(function(PdfRepository $repo) { return [ 'link' => [ 'href' => route('sendpayment.pdf', ['type' => get_class($repo)]), diff --git a/app/Payment/SendpaymentController.php b/app/Payment/SendpaymentController.php index 6c5c951e..4deb306c 100644 --- a/app/Payment/SendpaymentController.php +++ b/app/Payment/SendpaymentController.php @@ -4,8 +4,11 @@ namespace App\Payment; use App\Http\Controllers\Controller; use App\Pdf\PdfGenerator; +use App\Pdf\PdfRepository; use App\Pdf\PdfRepositoryFactory; +use Illuminate\Contracts\Support\Responsable; use Illuminate\Http\Request; +use Illuminate\Http\Response; use Inertia\Inertia; use Inertia\Response as InertiaResponse; @@ -22,6 +25,9 @@ class SendpaymentController extends Controller ]); } + /** + * @return Response|Responsable + */ public function send(Request $request) { $repo = app(PdfRepositoryFactory::class)->forAll($request->type, 'Post'); diff --git a/app/Pdf/MemberPdfController.php b/app/Pdf/MemberPdfController.php index f22e5096..b206a479 100644 --- a/app/Pdf/MemberPdfController.php +++ b/app/Pdf/MemberPdfController.php @@ -4,12 +4,16 @@ namespace App\Pdf; use App\Http\Controllers\Controller; use App\Member\Member; +use Illuminate\Contracts\Support\Responsable; use Illuminate\Http\Request; use Illuminate\Http\Response; class MemberPdfController extends Controller { + /** + * @return Response|Responsable + */ public function __invoke(Request $request, Member $member) { $repo = app(PdfRepositoryFactory::class)->fromSingleRequest($request->type, $member); diff --git a/app/Pdf/PdfRepositoryFactory.php b/app/Pdf/PdfRepositoryFactory.php index d70ee717..ff4cd4b4 100644 --- a/app/Pdf/PdfRepositoryFactory.php +++ b/app/Pdf/PdfRepositoryFactory.php @@ -10,14 +10,20 @@ use Illuminate\Support\Str; class PdfRepositoryFactory { + /** + * @var array> + */ private array $types = [ BillType::class, RememberType::class, ]; + /** + * @return Collection + */ public function getTypes(): Collection { - return collect($this->types); + return collect(array_map(fn ($classString) => new $classString, $this->types)); } public function fromSingleRequest(string $type, Member $member): ?PdfRepository diff --git a/tests/Lib/TestsInertia.php b/tests/Lib/TestsInertia.php index c0be848d..f887b0ff 100644 --- a/tests/Lib/TestsInertia.php +++ b/tests/Lib/TestsInertia.php @@ -7,6 +7,13 @@ use PHPUnit\Framework\Assert as PHPUnit; trait TestsInertia { + /** + * @param mixed $value + * @param TestResponse $response + * @param ?string $key + * + * @return void + */ public function assertInertiaHas($value, TestResponse $response, ?string $key = null): void { $bindings = json_decode(json_encode($value), true); @@ -23,6 +30,12 @@ trait TestsInertia { PHPUnit::assertEquals($component, $response->viewData('page')['component']); } + /** + * @param mixed $should + * @param mixed $is + * + * @return void + */ public function assertInertiaDeepNest($should, $is): void { foreach ($should as $key => $value) {