From 8c6635ea0bd94c3e26341d32427a492238a4483d Mon Sep 17 00:00:00 2001 From: philipp lang <philipp@aweos.de> Date: Sun, 12 Feb 2023 22:39:53 +0100 Subject: [PATCH] Lint --- src/Casters/CarbonCast.php | 5 ++++- src/Casters/NullValueCast.php | 3 +++ src/Casters/StringCast.php | 3 +++ src/Data/Member.php | 1 - src/Data/Membership.php | 3 +++ src/Fakes/CourseFake.php | 3 --- src/Fakes/MemberFake.php | 6 +++--- src/Group.php | 20 -------------------- src/MemberCollection.php | 17 ----------------- tests/Factories/MemberRequestFactory.php | 7 +++++-- tests/Unit/Api/FetchMemberTest.php | 2 ++ tests/Unit/Api/PutMemberTest.php | 4 ---- 12 files changed, 23 insertions(+), 51 deletions(-) delete mode 100644 src/MemberCollection.php diff --git a/src/Casters/CarbonCast.php b/src/Casters/CarbonCast.php index b47eab1..f2d73ef 100644 --- a/src/Casters/CarbonCast.php +++ b/src/Casters/CarbonCast.php @@ -11,10 +11,13 @@ use Spatie\LaravelData\Support\DataProperty; class CarbonCast implements Cast { public function __construct( - protected array|string|null $format = null + protected ?string $format = null ) { } + /** + * @param array<string, mixed> $context + */ public function cast(DataProperty $property, mixed $value, array $context): DateTimeInterface|Uncastable|null { if ($property->type->isNullable && !$value) { diff --git a/src/Casters/NullValueCast.php b/src/Casters/NullValueCast.php index fb8896f..265d36b 100644 --- a/src/Casters/NullValueCast.php +++ b/src/Casters/NullValueCast.php @@ -14,6 +14,9 @@ class NullValueCast implements Cast ) { } + /** + * @param array<string, mixed> $context + */ public function cast(DataProperty $property, mixed $value, array $context): DateTimeInterface|Uncastable|null|int { if ($this->id === $value) { diff --git a/src/Casters/StringCast.php b/src/Casters/StringCast.php index 3d985d6..dcaa6de 100644 --- a/src/Casters/StringCast.php +++ b/src/Casters/StringCast.php @@ -11,6 +11,9 @@ class StringCast implements Cast { } + /** + * @param array<string, mixed> $context + */ public function cast(DataProperty $property, mixed $value, array $context): ?string { if ($property->type->isNullable && !$value) { diff --git a/src/Data/Member.php b/src/Data/Member.php index 07c4d36..9565a2e 100644 --- a/src/Data/Member.php +++ b/src/Data/Member.php @@ -135,7 +135,6 @@ class Member extends Data 'wiederverwendenFlag' => $this->keepdata, 'regionId' => $this->regionId ?: 23, 'staatsangehoerigkeitId' => $this->nationalityId, - 'zeitschriftenversand' => $this->sendNewspaper, 'emailVertretungsberechtigter' => $this->emailParents, 'ort' => $this->location, 'plz' => $this->zip, diff --git a/src/Data/Membership.php b/src/Data/Membership.php index 0137693..e656421 100644 --- a/src/Data/Membership.php +++ b/src/Data/Membership.php @@ -35,6 +35,9 @@ class Membership extends Data ) { } + /** + * @return array<string, string|int|null> + */ public function toNami(): array { return [ diff --git a/src/Fakes/CourseFake.php b/src/Fakes/CourseFake.php index 6a99296..b555664 100644 --- a/src/Fakes/CourseFake.php +++ b/src/Fakes/CourseFake.php @@ -7,9 +7,6 @@ use Zoomyboy\LaravelNami\Data\Course; class CourseFake extends Fake { - private array $defaults = [ - ]; - /** * @param array<int> $ids */ diff --git a/src/Fakes/MemberFake.php b/src/Fakes/MemberFake.php index c5990a8..64a8f7c 100644 --- a/src/Fakes/MemberFake.php +++ b/src/Fakes/MemberFake.php @@ -86,7 +86,7 @@ class MemberFake extends Fake } /** - * @param array<string, string|int|null> $data + * @param array<string, string|int|bool|null> $data */ public function updatesSuccessfully(int $groupId, int $memberId, array $data = []): self { @@ -117,7 +117,7 @@ class MemberFake extends Fake } /** - * @param array<string, string|int|null> $body + * @param array<string, string|int|bool|null> $body */ public function assertCreated(int $groupId, array $body): void { @@ -145,7 +145,7 @@ class MemberFake extends Fake } /** - * @param array<string, string|int|null> $body + * @param array<string, string|int|bool|null> $body */ public function assertUpdated(int $groupId, int $memberId, array $body): void { diff --git a/src/Group.php b/src/Group.php index a6b8afd..67f220d 100644 --- a/src/Group.php +++ b/src/Group.php @@ -55,26 +55,6 @@ class Group implements Arrayable return Nami::feesOf($this->id); } - public function members(): MemberCollection - { - $members = Nami::membersOf($this->id); - - return MemberCollection::make(function () use ($members) { - foreach ($members as $member) { - yield $this->member($member['id']); - } - }); - - return new MemberCollection(Nami::membersOf($this->id)->map(function ($member) { - return $this->member($member['id']); - })); - } - - public function member(int $id): Member - { - return Member::fromNami(Nami::member($this->id, $id)); - } - public function activities(): Collection { return Nami::activities($this->id); diff --git a/src/MemberCollection.php b/src/MemberCollection.php deleted file mode 100644 index 4ab547f..0000000 --- a/src/MemberCollection.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php - -namespace Zoomyboy\LaravelNami; - -use Illuminate\Support\LazyCollection; - -class MemberCollection extends LazyCollection -{ - public static function fromOverview($items) - { - $self = new self($items); - - return $self->map(function ($item) { - return Member::fromOverview($item); - }); - } -} diff --git a/tests/Factories/MemberRequestFactory.php b/tests/Factories/MemberRequestFactory.php index 37351aa..df68905 100644 --- a/tests/Factories/MemberRequestFactory.php +++ b/tests/Factories/MemberRequestFactory.php @@ -2,13 +2,16 @@ namespace Zoomyboy\LaravelNami\Tests\Factories; -use GuzzleHttp\Promise\FulfilledPromise; +use GuzzleHttp\Promise\PromiseInterface; use Illuminate\Support\Facades\Http; use Worksome\RequestFactories\RequestFactory; use Zoomyboy\LaravelNami\Data\Member; class MemberRequestFactory extends RequestFactory { + /** + * @return array<string, mixed> + */ public function definition(): array { return [ @@ -48,7 +51,7 @@ class MemberRequestFactory extends RequestFactory ]); } - public function toSingleHttp(): FulfilledPromise + public function toSingleHttp(): PromiseInterface { return Http::response(json_encode([ 'success' => true, diff --git a/tests/Unit/Api/FetchMemberTest.php b/tests/Unit/Api/FetchMemberTest.php index a35dcab..926e4ae 100644 --- a/tests/Unit/Api/FetchMemberTest.php +++ b/tests/Unit/Api/FetchMemberTest.php @@ -116,6 +116,8 @@ class FetchMemberTest extends TestCase /** * @testWith [{"eintrittsdatum": null}] * [{"landId": null}] + * + * @param array<string, mixed> $data */ public function testFailsFetchingWhenJoinedAtDateIsMissing(array $data): void { diff --git a/tests/Unit/Api/PutMemberTest.php b/tests/Unit/Api/PutMemberTest.php index fd7089d..d863d6d 100644 --- a/tests/Unit/Api/PutMemberTest.php +++ b/tests/Unit/Api/PutMemberTest.php @@ -22,8 +22,6 @@ class PutMemberTest extends TestCase 'birthday' => '2021-02-02 00:00:00', 'email' => 'aa@b.de', 'countryId' => 78, - 'keepdata' => false, - 'sendNewspaper' => false, 'regionId' => 11, 'nationalityId' => 12, 'beitragsartId' => null, @@ -55,8 +53,6 @@ class PutMemberTest extends TestCase 'geburtsDatum' => '2021-02-02 00:00:00', 'konfessionId' => 33, 'landId' => 78, - 'wiederverwendenFlag' => false, - 'zeitschriftenversand' => false, 'regionId' => 11, 'staatsangehoerigkeitId' => 12, 'ersteTaetigkeitId' => 78,