From 7c876d75c9b6ec9fd36511b743beae0d40532878 Mon Sep 17 00:00:00 2001 From: philipp lang Date: Sun, 22 Sep 2024 03:00:09 +0200 Subject: [PATCH] Update casters --- src/Casters/CarbonCast.php | 5 +---- src/Casters/GroupCast.php | 3 --- src/Casters/NullValueCast.php | 3 --- src/Casters/StringCast.php | 3 --- tests/Unit/Api/PutMemberTest.php | 10 +++++----- 5 files changed, 6 insertions(+), 18 deletions(-) diff --git a/src/Casters/CarbonCast.php b/src/Casters/CarbonCast.php index e9eedad..4471e8b 100644 --- a/src/Casters/CarbonCast.php +++ b/src/Casters/CarbonCast.php @@ -17,9 +17,6 @@ class CarbonCast implements Cast ) { } - /** - * @param array $context - */ public function cast(DataProperty $property, mixed $value, array $properties, CreationContext $context): DateTimeInterface|Uncastable|null { if ($property->type->isNullable && !$value) { @@ -27,7 +24,7 @@ class CarbonCast implements Cast } try { - return (new DateTimeInterfaceCast($this->format, null, null, null))->cast($property, $value, $context); + return (new DateTimeInterfaceCast($this->format, null, null, null))->cast($property, $value, $properties, $context); } catch (CannotCastDate $e) { if (!$property->type->isNullable) { throw $e; diff --git a/src/Casters/GroupCast.php b/src/Casters/GroupCast.php index fad0a19..d69390d 100644 --- a/src/Casters/GroupCast.php +++ b/src/Casters/GroupCast.php @@ -12,9 +12,6 @@ class GroupCast implements Cast { } - /** - * @param array $context - */ public function cast(DataProperty $property, mixed $value, array $properties, CreationContext $context): ?string { if ($property->type->isNullable && !$value) { diff --git a/src/Casters/NullValueCast.php b/src/Casters/NullValueCast.php index 4cc5682..c52dfad 100644 --- a/src/Casters/NullValueCast.php +++ b/src/Casters/NullValueCast.php @@ -15,9 +15,6 @@ class NullValueCast implements Cast ) { } - /** - * @param array $context - */ public function cast(DataProperty $property, mixed $value, array $properties, CreationContext $context): DateTimeInterface|Uncastable|null|int { if ($this->id === $value) { diff --git a/src/Casters/StringCast.php b/src/Casters/StringCast.php index 24bcb8a..27c66c6 100644 --- a/src/Casters/StringCast.php +++ b/src/Casters/StringCast.php @@ -12,9 +12,6 @@ class StringCast implements Cast { } - /** - * @param array $context - */ public function cast(DataProperty $property, mixed $value, array $properties, CreationContext $context): ?string { if ($property->type->isNullable && !$value) { diff --git a/tests/Unit/Api/PutMemberTest.php b/tests/Unit/Api/PutMemberTest.php index d7fb72d..b7dacbd 100644 --- a/tests/Unit/Api/PutMemberTest.php +++ b/tests/Unit/Api/PutMemberTest.php @@ -11,7 +11,7 @@ class PutMemberTest extends TestCase public function testPushASingleMember(): void { app(MemberFake::class)->stores(103, 16); - $member = Member::factory()->toMember([ + $member = Member::toFactory()->toMember([ 'firstname' => 'Max', 'lastname' => 'Nach1', 'nickname' => 'spitz1', @@ -79,7 +79,7 @@ class PutMemberTest extends TestCase app(MemberFake::class) ->updatesSuccessfully(103, 16) ->shows(103, 16); - $member = Member::factory()->toMember([ + $member = Member::toFactory()->toMember([ 'firstname' => 'Max', 'lastname' => 'Nach1', 'nickname' => 'spitz1', @@ -123,7 +123,7 @@ class PutMemberTest extends TestCase app(MemberFake::class) ->updatesSuccessfully(103, 16) ->shows(103, 16); - $member = Member::factory()->toMember([ + $member = Member::toFactory()->toMember([ 'email' => null, 'groupId' => 103, 'id' => 16, @@ -145,7 +145,7 @@ class PutMemberTest extends TestCase 'foreign' => 'fff', 'kontoverbindung' => ['a' => 'b'], ]); - $response = $this->login()->putMember(Member::factory()->inNami(103, 16)->toMember()); + $response = $this->login()->putMember(Member::toFactory()->inNami(103, 16)->toMember()); $this->assertEquals(16, $response); @@ -163,7 +163,7 @@ class PutMemberTest extends TestCase 'foreign' => 'fff', 'kontoverbindung' => ['a' => 'b'], ]); - $response = $this->login()->putMember(Member::factory()->inNami(103, 16)->toMember(['genderId' => null, 'regionId' => null])); + $response = $this->login()->putMember(Member::toFactory()->inNami(103, 16)->toMember(['genderId' => null, 'regionId' => null])); $this->assertEquals(16, $response);